home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / dino / dino_bot.1 / source / install / cinstall.c next >
Encoding:
C/C++ Source or Header  |  1991-06-14  |  107.3 KB  |  3,146 lines

  1. /* Copyright, 1990, Regents of the University of Colorado */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <sys/types.h>
  6. #include <sys/param.h>
  7. #include <ctype.h>
  8. #include <sys/stat.h>
  9. #include <sys/timeb.h>
  10. #include <sys/wait.h>
  11. #include <malloc.h>
  12. #include <errno.h>
  13. #include <varargs.h>
  14. #include <fcntl.h>
  15. #include <dirent.h>
  16. #include <utime.h>
  17.  
  18. #define BOOL char
  19. #define TRUE 1
  20. #define FALSE 0
  21.  
  22. #define MAXLINESIZE 256
  23. #define MAXMACHINES 10
  24. #define MAXMACHNAME 20
  25. #define NAMESIZE 15
  26. #define BUFSIZE 2048
  27.  
  28. extern void exit();
  29. extern char *getenv();
  30.  
  31. static int get_yn();
  32. static void get_line();
  33. static int get_line_quit();
  34. static void copy();
  35. static void copyerr();
  36. static void maked();
  37.  
  38. #include "messages.h"
  39.  
  40. /********************************************************************
  41.  *
  42.  *  List of FATAL SYSTEM ERRORS:
  43.  *
  44.  *     1: No "USER" environment variable found.
  45.  *
  46.  *     2: No "PATH" environment variable found.
  47.  *
  48.  *     3: No "PWD" environment variable found.
  49.  *
  50.  *     4: Unable to open existing "dino.init" file for reading.
  51.  *
  52.  *     5: Unable to set up pipe for redirecting stdout and stderr.
  53.  *
  54.  *     6: Unable to open new file (. . .) for writing.
  55.  *
  56.  *     7: Unable to open existing "D..." files in /source/install
  57.  *        for reading.
  58.  *
  59.  *     8: Unable to create directory.
  60.  *
  61.  *     9: Unable to copy file.
  62.  *
  63.  *    10: Unable to establish symbolic link.
  64.  *
  65.  *    11: Unable to determine architecture type.
  66.  *
  67.  *******************************************************************/
  68.  
  69. main()
  70.    {
  71.     int I, J;
  72.     char enter[MAXLINESIZE], line[MAXLINESIZE];
  73.     char dir[MAXPATHLEN], name[MAXPATHLEN], name2[MAXPATHLEN];
  74.     char targetd[MAXPATHLEN], sourced[MAXPATHLEN];
  75.     char target[NAMESIZE];
  76.     char sim1loc[MAXPATHLEN], sim2loc[MAXPATHLEN];
  77.     struct stat buf1, buf2;
  78.     FILE *init, *input, *testf, *output;
  79.     BOOL update = FALSE;
  80.     BOOL newarch = FALSE;
  81.     BOOL source = TRUE;
  82.     BOOL pc = FALSE;
  83.     BOOL partial = FALSE;
  84.     BOOL bingo = FALSE;
  85.     BOOL malformed;
  86.     BOOL restart, done;
  87.     BOOL sim1 = FALSE, sim2 = FALSE, grail = FALSE;
  88.     BOOL local2 = FALSE;
  89.     BOOL backend = TRUE;
  90.     char *path, *current, *arch, *user;
  91.     char *cptr1, *cptr2, *cptr3, *cptr4;
  92.     char holder, inst_type;
  93.     int M = 0;
  94.     int tempi, fdes[2];
  95.     int choice;
  96.     int dfalt = 0;
  97.     int status;
  98.  
  99.     static struct {
  100.                     char name[MAXMACHNAME];
  101.                     char address[MAXPATHLEN];
  102.                     char user[NAMESIZE];
  103.                     char directory[MAXPATHLEN];
  104.                     char rmt_directory[MAXPATHLEN];
  105.                     char lcl_directory[MAXPATHLEN];
  106.                     char rmt_user[NAMESIZE];
  107.                     char rmt_install;
  108.                     char type;
  109.                     int maxdim;
  110.                     int dim;
  111.                     char rcp;
  112.                     char rsh;
  113.                     char run;
  114.                     char date;
  115.                     BOOL xmt;
  116.                     BOOL home;
  117.                     BOOL install;
  118.                   } machines[MAXMACHINES];
  119.  
  120.  
  121.         /* Print out the initial message. */
  122.  
  123.     (void) fprintf(stderr, "%s", messages[0]);
  124.     get_line(enter);
  125.     if (enter[0] =='Q' || enter[0] == 'q')
  126.         return(0);
  127.  
  128.         /* First, check that DINO is properly installed. */
  129.  
  130.     (void) fprintf(stderr,
  131.         "\n\n    Checking the DINO system defaults . . .\n\n");
  132.  
  133.         /* Make sure the "ARCHTYPE" variable is set correctly. */
  134.  
  135.     if ((arch = getenv("ARCHTYPE")) != NULL)
  136.        {
  137.         if (strcmp(arch, "sun3") != 0 && strcmp(arch, "sun4") != 0)
  138.            {
  139.             (void) fprintf(stderr,"%s\"%s\".\n%s",
  140.                                 messages[72], arch, messages[73]);
  141.             exit(1);
  142.            }
  143.        }
  144.     else
  145.        {
  146.         if (pipe(fdes))
  147.            {
  148.             (void) fprintf(stderr,
  149.           "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
  150.             exit(1);
  151.            }
  152.         if (fork())
  153.            {
  154.             (void) wait(NULL);
  155.             arch = malloc((unsigned) NAMESIZE);
  156.             tempi = read(fdes[0], arch, MAXLINESIZE);
  157.             if (arch[tempi-1] == '\n')
  158.                 arch[tempi-1] = '\0';
  159.             else
  160.                 arch[tempi] = '\0';
  161.             (void) close(fdes[0]);
  162.             (void) close(fdes[1]);
  163.            }
  164.         else
  165.            {
  166.             (void) dup2(fdes[1], 1);
  167.             (void) execlp("/usr/bin/arch", "arch", 0);
  168.            }
  169.         (void) fprintf(stderr, "%s", messages[1]);
  170.        }
  171.     if (strcmp(arch, "sun3") != 0 && strcmp(arch, "sun4") != 0)
  172.        {
  173.         (void) fprintf(stderr,
  174.           "\n\nFATAL SYSTEM ERROR 11; contact dino@cs.colorado.edu for help\n\n");
  175.         exit(1);
  176.        }
  177.  
  178.  
  179.     if ((user = getenv("USER")) == NULL)
  180.        {
  181.         (void) fprintf(stderr,
  182.           "\n\nFATAL SYSTEM ERROR 1: Contact dino@cs.colorado.edu for help\n\n");
  183.         exit(1);
  184.        }
  185.     if ((path = getenv("PATH")) == NULL)
  186.        {
  187.         (void) fprintf(stderr,
  188.           "\n\nFATAL SYSTEM ERROR 2: Contact dino@cs.colorado.edu for help\n\n");
  189.         exit(1);
  190.        }
  191.     if ((current = getenv("PWD")) == NULL)
  192.        {
  193.         (void) fprintf(stderr,
  194.           "\n\nFATAL SYSTEM ERROR 3: Contact dino@cs.colorado.edu for help\n\n");
  195.         exit(1);
  196.        }
  197.     if (strncmp(current, "/tmp_mnt", 8) == 0)
  198.        {
  199.         for (I = 8; current[I] != '\0'; I++)
  200.             current[I-8] = current[I];
  201.         current[I-8] = '\0';
  202.         (void) fprintf(stderr, "%s", messages[66]);
  203.        }
  204.  
  205.         /* Find out if the user has write permission here. */
  206.  
  207.     if ((testf = fopen("_D_TEST", "w")) == NULL)
  208.        {
  209.         (void) fprintf(stderr,
  210.                     "        DINO is not able to write into %s\n", current);
  211.         (void) fprintf(stderr,
  212. "        This is probably because %s does not have write permission here.\n\n",
  213.                                                                         user);
  214.         (void) fprintf(stderr,
  215.             "    When you have fixed this problem, run \"install\" again.\n\n");
  216.         return(0);
  217.        }
  218.     else
  219.        {
  220.         (void) fclose(testf);
  221.         (void) unlink("_D_TEST");
  222.        }
  223.  
  224.         /* Find out if there is a Pascal compiler in the path. */
  225.  
  226.     for (cptr1 = cptr2 = path; *cptr2 != '\0'; cptr2++, cptr1 = cptr2)
  227.        {
  228.         for (; *cptr2 != '\0' && *cptr2 != ':'; cptr2++);
  229.         for (cptr3 = cptr1, cptr4 = &(name[0]);
  230.                                          cptr3 != cptr2; cptr4++, cptr3++)
  231.             *cptr4 = *cptr3;
  232.         *(cptr4++) = '/';
  233.         *(cptr4++) = 'p';
  234.         *(cptr4++) = 'c';
  235.         *(cptr4++) = '\0';
  236.         if (stat(name, &buf1) == 0)
  237.            {
  238.             if (S_ISREG(buf1.st_mode) && (buf1.st_mode & S_IXOTH))
  239.                {
  240.                 pc = TRUE;
  241.                 break;
  242.                }
  243.            }
  244.        }
  245.  
  246.         /* Find out if there is a compiler executable here and if
  247.                         it is newer than any compiler source files. */
  248.  
  249.     (void) sprintf(name, "%s/bin/%s/d.exe", current, arch);
  250.     if (stat(name, &buf1) == 0)
  251.        {
  252.         (void) sprintf(name, "%s/source/compiler/walk.p", current);
  253.         if (stat(name, &buf2) == 0)
  254.            {
  255.             if (buf2.st_mtime > buf1.st_mtime)
  256.                {
  257.                 if (!pc)
  258.                    {
  259.                     partial= TRUE;
  260.                     (void) fprintf(stderr, "%s", messages[2]);
  261.                      get_line(enter);
  262.                     if (enter[0] =='Q' || enter[0] == 'q')
  263.                        {
  264.                         (void) fprintf(stderr,
  265.         "\n\n    When you have fixed this problem, run \"install\" again.\n\n");
  266.                         return(0);
  267.                        }
  268.                     else
  269.                        {
  270.                         (void) fprintf(stderr,"\n\n");
  271.                         source = FALSE;
  272.                        }
  273.                    }
  274.                }
  275.             else
  276.                 source = FALSE;
  277.            }
  278.         else
  279.             source = FALSE;
  280.        }
  281.     else
  282.        {
  283.         if (!pc)
  284.            {
  285.             (void) fprintf(stderr, "%s", messages[3]);
  286.             return(0);
  287.            }
  288.        }
  289.  
  290.  
  291.     if (partial)
  292.        {
  293.         (void) fprintf(stderr,
  294.         "    All DINO system defaults are correct\n");
  295.         (void) fprintf(stderr,
  296.         "         (except the missing Pascal compiler).\n\n\n");
  297.       }
  298.     else
  299.         (void) fprintf(stderr,
  300.                     "    All DINO system defaults are correct.\n\n\n");
  301.  
  302.         /* Determine if this is a new installation or an update. */
  303.  
  304.     if (stat("bin/local/dino.init", &buf1) == 0)
  305.        {
  306.         if ((init = fopen("bin/local/dino.init", "r")) == NULL)
  307.            {
  308.             (void) fprintf(stderr,
  309.          "\n\nFATAL SYSTEM ERROR 4: Contact dino@cs.colorado.edu for help\n\n");
  310.             exit(1);
  311.            }
  312.         update = TRUE;
  313.  
  314.         /* Determine if we are installing
  315.                             the other architecture (sun3 or sun4) */
  316.  
  317.     (void) sprintf(name, "bin/%s/dino", arch);
  318.     if (stat(name, &buf1) != 0)
  319.         newarch = TRUE;
  320.  
  321.  
  322.             /* If so, get the existing system configuration from dino.init. */
  323.  
  324.         for (holder = ' ';;)
  325.            {
  326.             if (holder == EOF) break;
  327.             holder = getc(init);
  328.             if (holder == '#')
  329.                {
  330.                 for (; (holder = getc(init)) != '\n' && holder != EOF;);
  331.                 continue;
  332.                }
  333.             for (; holder != 'D' && holder != EOF && holder != '\n';
  334.                                                         holder = getc(init));
  335.             if (holder == EOF) break;
  336.             if (holder == '\n') continue;
  337.             if (getc(init) != 'm')
  338.                {
  339.                 for (; (holder = getc(init)) != '\n' && holder != EOF;);
  340.                 continue;
  341.                }
  342.             if (getc(init) != 'a')
  343.                {
  344.                 for (; (holder = getc(init)) != '\n' && holder != EOF;);
  345.                 continue;
  346.                }
  347.             if (getc(init) != 'c')
  348.                {
  349.                 for (; (holder = getc(init)) != '\n' && holder != EOF;);
  350.                 continue;
  351.                }
  352.             if (getc(init) != 'h')
  353.                {
  354.                 for (; (holder = getc(init)) != '\n' && holder != EOF;);
  355.                 continue;
  356.                }
  357.             if (getc(init) != 's')
  358.                {
  359.                 for (; (holder = getc(init)) != '\n' && holder != EOF;);
  360.                 continue;
  361.                }
  362.             if (getc(init) != '=')
  363.                {
  364.                 for (; (holder = getc(init)) != '\n' && holder != EOF;);
  365.                 continue;
  366.                }
  367.             if (getc(init) != '"')
  368.                {
  369.                 for (; (holder = getc(init)) != '\n' && holder != EOF;);
  370.                 continue;
  371.                }
  372.             for (;;)
  373.                {
  374.                 malformed = FALSE;
  375.                 if (fscanf(init, " %s %s %s %s %c%d%c%c%c%c%d",
  376.                                              machines[M].name,
  377.                                              machines[M].address,
  378.                                              machines[M].user,
  379.                                              machines[M].directory,
  380.                                              &machines[M].type,
  381.                                              &machines[M].maxdim,
  382.                                              &machines[M].rcp,
  383.                                              &machines[M].rsh,
  384.                                              &machines[M].run,
  385.                                              &machines[M].date,
  386.                                              &machines[M].dim) != 11)
  387.                     malformed = TRUE;
  388.                 if (machines[M].name[0] =='#' ||
  389.                                              machines[M].address[0] =='#' ||
  390.                                              machines[M].user[0] =='#' ||
  391.                                              machines[M].directory[0] =='#')
  392.                     malformed = TRUE;
  393.                 switch (machines[M].type)
  394.                    {
  395.                     case 's':
  396.                     case 'S':
  397.                     case '1':
  398.                     case '2':
  399.                     case '8':
  400.                     case 'G': break;
  401.                     default: malformed = TRUE;
  402.                    }
  403.                 switch (machines[M].rcp)
  404.                    {
  405.                     case 'T':
  406.                     case 'F': break;
  407.                     default: malformed = TRUE;
  408.                    }
  409.                 switch (machines[M].rsh)
  410.                    {
  411.                     case 'T':
  412.                     case 'F': break;
  413.                     default: malformed = TRUE;
  414.                    }
  415.                 switch (machines[M].run)
  416.                    {
  417.                     case 'T':
  418.                     case 'F':
  419.                     case 'S': break;
  420.                     default: malformed = TRUE;
  421.                    }
  422.                 switch (machines[M].date)
  423.                    {
  424.                     case 'T':
  425.                     case 'F': break;
  426.                     default: malformed = TRUE;
  427.                    }
  428.  
  429.                 if (malformed)
  430.                    {
  431.                     (void) fprintf(stderr, "%s", messages[4]);
  432.                     return(0);
  433.                    }
  434.                 M++;
  435.                 for (; (holder = getc(init)) == ' ' || holder == '\t';);
  436.                 if (holder == '"')
  437.                    {
  438.                     bingo = TRUE;
  439.                     break;
  440.                    }
  441.                 if (holder != '\\')
  442.                     (void) ungetc(holder, init);
  443.                }
  444.             if (bingo) break;
  445.            }
  446.         if (bingo)
  447.            {
  448.             bingo = FALSE;
  449.             for (; holder != '\n' && holder != EOF; holder = getc(init));    
  450.             for (;;)
  451.                {
  452.                 for (; (holder == ' ' || holder == '\t' || holder == '\n') &&
  453.                                             holder != EOF; holder = getc(init));
  454.                 if (holder == EOF) break;
  455.                 if (holder == '#')
  456.                    {
  457.                     holder = getc(init);
  458.                     if (holder == EOF) break;
  459.                     if (holder == '#')
  460.                        {
  461.                         (void) fscanf(init,
  462.                                     " %s = (%c) %s", name, &inst_type, line);
  463.                         for (I = 0; I < M; I++)
  464.                             if (strcmp(name, machines[I].name) == 0)
  465.                                {
  466.                                 if (inst_type == 'R'  || inst_type == 'L' ||
  467.                                             inst_type == 'M'|| inst_type == 'N')
  468.                                    {
  469.                                     (void) strcpy(machines[I].rmt_directory,
  470.                                                                             line);
  471.                                     machines[I].rmt_install = inst_type;
  472.                                     switch (inst_type)
  473.                                        {
  474.                                         case 'L':
  475.                                             (void) fscanf(init," ## %s",
  476.                                                      machines[I].lcl_directory);
  477.                                             break;
  478.                                         case 'R':
  479.                                         case 'M':
  480.                                             (void) sprintf(
  481.                                                     machines[I].lcl_directory,
  482.                                                     "%s/%s", current,
  483.                                                         machines[I].name);
  484.                                             break;
  485.                                         case 'N':
  486.                                             (void) strcpy(
  487.                                                     machines[I].lcl_directory,
  488.                                                     machines[I].rmt_directory);
  489.                                             break;
  490.                                        }
  491.                                     break;
  492.                                    }
  493.                                 else
  494.                                    {
  495.                                     I = M;
  496.                                     break;
  497.                                    }
  498.                                }
  499.                         if (I == M) break;
  500.                         while (fscanf(init,
  501.                                 " ## %s=(%c) %s", name, &inst_type, line) == 3)
  502.                            {
  503.                             for (I = 0; I < M; I++)
  504.                                 if (strcmp(name, machines[I].name) == 0)
  505.                                    {
  506.                                     if (inst_type == 'R'  || inst_type == 'L' ||
  507.                                             inst_type == 'M'|| inst_type == 'N')
  508.                                        {
  509.                                         (void) strcpy(machines[I].rmt_directory,
  510.                                                                             line);
  511.                                         machines[I].rmt_install = inst_type;
  512.                                         switch (inst_type)
  513.                                            {
  514.                                             case 'L':
  515.                                                 (void) fscanf(init," ## %s",
  516.                                                       machines[I].lcl_directory);
  517.                                                 break;
  518.                                             case 'R':
  519.                                             case 'M':
  520.                                                 (void) sprintf(
  521.                                                         machines[I].lcl_directory,
  522.                                                         "%s/%s", current,
  523.                                                             machines[I].name);
  524.                                                 break;
  525.                                             case 'N':
  526.                                                 (void) strcpy(
  527.                                                       machines[I].lcl_directory,
  528.                                                       machines[I].rmt_directory);
  529.                                                 break;
  530.                                            }
  531.                                         break;
  532.                                        }
  533.                                     else
  534.                                         {
  535.                                         I = M;
  536.                                         break;
  537.                                        }
  538.                                    }
  539.                             if (I == M) break;
  540.                            }
  541.                         if (I != M)
  542.                             bingo = TRUE;
  543.                         break;
  544.                        }
  545.                     else
  546.                         for (; holder != '\n' && holder != EOF;
  547.                                                             holder = getc(init));
  548.                    }
  549.                 else
  550.                     for (; holder != '\n' && holder != EOF; holder = getc(init));
  551.                }
  552.            }
  553.         (void) fclose(init);
  554.         if (! bingo)
  555.            {
  556.             (void) fprintf(stderr, "%s", messages[5]);
  557.             return(0);
  558.            }
  559.         else
  560.            {
  561.             (void) fprintf(stderr, "%s", messages[6]);
  562.             for(;;)
  563.                {
  564.                 (void) fprintf(stderr, "             (Y/N) ==> ");
  565.                 get_line(enter);
  566.                 if (enter[0] != 'Y' && enter[0] != 'y' &&
  567.                                               enter[0] != 'N' && enter[0] != 'n')
  568.                    {
  569.                     (void) fprintf(stderr,
  570.                   "\n        (You should enter either a \"Y\" or a \"N\".)\n\n");
  571.                     continue;
  572.                    }
  573.                 else
  574.                    {
  575.                     if (enter[0] == 'N' || enter[0] == 'n')
  576.                         return(0);
  577.                     else
  578.                         break;
  579.                    }
  580.                }
  581.            }
  582.         (void) fprintf(stderr, "\n\n%s%s%s\n\n", messages[60], arch, messages[61]);
  583.         for(;;)
  584.            {
  585.             (void) fprintf(stderr, "             (Y/N) ==> ");
  586.             get_line(enter);
  587.             if (enter[0] != 'Y' && enter[0] != 'y' &&
  588.                                           enter[0] != 'N' && enter[0] != 'n')
  589.                {
  590.                 (void) fprintf(stderr,
  591.               "\n        (You should enter either a \"Y\" or a \"N\".)\n\n");
  592.                 continue;
  593.                }
  594.             else
  595.                {
  596.                 if (enter[0] == 'N' || enter[0] == 'n')
  597.                     backend = FALSE;
  598.                 break;
  599.                }
  600.            }
  601.  
  602.        }
  603.     else
  604.        {
  605.             /* There was no "dino.init" file, so assume that
  606.                                         this is a new installation. */
  607.  
  608.         (void) fprintf(stderr, "%s", messages[7]);
  609.         get_line(enter);
  610.         if (enter[0] =='Q' || enter[0] == 'q')
  611.             return(0);
  612.  
  613.             /* For each machine the user decides to define: */
  614.  
  615.         for(M = 0;;)
  616.            {
  617.  
  618.                 /* Get the name of the machine. */
  619.  
  620.             (void) fprintf(stderr, "%s%d%s", messages[8], M + 1, messages[9]);
  621.             get_line(enter);
  622.             if (enter[0] =='\0')
  623.                {
  624.                 (void) fprintf(stderr,
  625. "\n    If you want to quit the Automated Installer, enter a \"Q\" now;\n");
  626.                 (void) fprintf(stderr,
  627. "    if you want to record the existing configurations, enter a \"R\" now;\n");
  628.                 (void) fprintf(stderr,
  629. "    otherwise just hit enter to start machine #%d over ==>", M + 1);
  630.                 get_line(enter);
  631.                 if (enter[0] =='Q' || enter[0] == 'q')
  632.                     return(0);
  633.                 else
  634.                     if (enter[0] =='R' || enter[0] == 'r')
  635.                         break;
  636.                     else
  637.                         continue;
  638.                }
  639.             restart = FALSE;
  640.             for (I = 0; I < M; I++)
  641.                 if (strcmp(enter, machines[I].name) == 0)
  642.                    {
  643.                     (void) fprintf(stderr,
  644. "\n        There is already a machine name %s defined.\n", enter);
  645.                     (void) fprintf(stderr,
  646. "             You can not use the same name again.\n\n");
  647.                     restart = TRUE;
  648.                     break;
  649.                    }
  650.             if (restart) continue;
  651.             (void) strcpy(machines[M].name, enter);
  652.  
  653.             machines[M].user[0] = '~';
  654.             machines[M].user[1] = '\0';
  655.  
  656.                 /* Get the type of machine. */
  657.  
  658.             for (;;)
  659.                {
  660.                 (void) fprintf(stderr, "%s%s%s", messages[10],
  661.                                                 machines[M].name, messages[11]);
  662.             restart = FALSE;
  663.             if (get_line_quit(enter, M+1))
  664.                {
  665.                 restart = TRUE;
  666.                 break;
  667.                }
  668.             switch (enter[0])
  669.                {
  670.                 case 's':
  671.                     machines[M].type = enter[0];
  672.                     machines[M].rsh = 'F';
  673.                     machines[M].directory[0] = '.';
  674.                     machines[M].directory[1] = '\0';
  675.                     machines[M].address[0] = '.';
  676.                     machines[M].address[1] = '\0';
  677.                     machines[M].rcp = 'F';
  678.                     machines[M].run = 'T';
  679.                     machines[M].xmt = TRUE;
  680.                     machines[M].home = TRUE;
  681.                     machines[M].date = 'T';
  682.                     done = TRUE;
  683.                     break;
  684.                 case 'S':
  685.                     machines[M].type = enter[0];
  686.                     machines[M].rsh = 'F';
  687.                     machines[M].directory[0] = '.';
  688.                     machines[M].directory[1] = '\0';
  689.                     machines[M].address[0] = '.';
  690.                     machines[M].address[1] = '\0';
  691.                     machines[M].rcp = 'F';
  692.                     machines[M].run = 'T';
  693.                     machines[M].xmt = TRUE;
  694.                     machines[M].home = TRUE;
  695.                     machines[M].date = 'T';
  696.                     done = TRUE;
  697.                     break;
  698.                 case '1':
  699.                     machines[M].type = enter[0];
  700.                     machines[M].rsh = 'T';
  701.                     machines[M].directory[0] = '~';
  702.                     machines[M].directory[1] = '\0';
  703.                     machines[M].rcp = 'T';
  704.                     machines[M].xmt = FALSE;
  705.                     machines[M].home = FALSE;
  706.                     machines[M].date = 'F';
  707.                     done = TRUE;
  708.                     break;
  709.                 case '2':
  710.                     machines[M].type = enter[0];
  711.                     machines[M].rsh = 'T';
  712.                     machines[M].directory[0] = '~';
  713.                     machines[M].directory[1] = '\0';
  714.                     machines[M].date = 'T';
  715.                     done = TRUE;
  716.                     break;
  717.                 case '8':
  718.                     machines[M].type = enter[0];
  719.                     machines[M].rsh = 'T';
  720.                     machines[M].directory[0] = '~';
  721.                     machines[M].date = 'T';
  722.                     machines[M].directory[1] = '\0';
  723.                     done = TRUE;
  724.                     break;
  725.                 case 'G':
  726.                     (void) fprintf(stderr,
  727. "\n        Sorry, \"G\" is not implemented at this time.  Please try\n");
  728.                     (void) fprintf(stderr, "        another choice.\n");
  729.                     done = FALSE;
  730.                     break;
  731.                 default:
  732.                     (void) fprintf(stderr,
  733. "\n        Sorry, \"%c\" is not one of the allowed choices.  Please\n",
  734.                                                                   enter[0]);
  735.                     (void) fprintf(stderr, "        try again.\n");
  736.                     done = FALSE;
  737.                     break;
  738.                }
  739.             if ( done)
  740.                 break;
  741.            }
  742.         if (restart)
  743.             continue;
  744.  
  745.         if (machines[M].type == 's' && ! sim1)
  746.            {
  747.             for (;;)
  748.                {
  749.                 restart = FALSE;
  750.                 (void) fprintf(stderr, "%siPSC1\n%s", messages[67], messages[68]);
  751.                 if (get_line_quit(enter, M+1))
  752.                     restart = TRUE;
  753.                 else
  754.                    {
  755.                     if ((cptr1 = strstr(enter, "${ARCHTYPE}")) != NULL ||
  756.                                             (cptr1 = strstr(enter, "$ARCHTYPE")) != NULL)
  757.                        {
  758.                         for (cptr2 = &(enter[0]), cptr3 = &(dir[0]);
  759.                                                 cptr2 != cptr1; *(cptr3++) = *(cptr2++));
  760.                         for (cptr1 = &(arch[0]); *cptr1 != '\0'; *(cptr3++) = *(cptr1++));
  761.                         for (; *cptr2 != '/'; cptr2++);
  762.                         for (; *cptr2 != '\0'; *(cptr3++) = *(cptr2++));
  763.                         *cptr3 = '\0';
  764.                        }
  765.                     else
  766.                         (void) strcpy(dir, enter);
  767.                     if (stat(dir, &buf1) != 0 || ! S_ISREG(buf1.st_mode))
  768.                        {
  769.                         (void) fprintf(stderr,
  770.                             "\n        The file: %s\n%s", dir, messages[15]);
  771.                             (void) fprintf(stderr, "%d%s", M+1, messages[16]);
  772.                         get_line(enter);
  773.                         if (enter[0] =='Q' || enter[0] == 'q')
  774.                             return(0);
  775.                         else
  776.                             if (enter[0] =='R' || enter[0] == 'r')
  777.                                 restart = TRUE;
  778.                        }
  779.                     else
  780.                        {
  781.                         (void) strcpy(sim1loc, enter);
  782.                         break;
  783.                        }
  784.                    }
  785.                 if (restart)
  786.                     break;
  787.                }
  788.             if (restart)
  789.                 continue;
  790.             else
  791.                 sim1 = TRUE;
  792.            }
  793.  
  794.         if (machines[M].type == 'S' && ! sim2)
  795.            {
  796.             for (;;)
  797.                {
  798.                 restart = FALSE;
  799.                 (void) fprintf(stderr, "%siPSC2\n%s", messages[67], messages[68]);
  800.                 if (get_line_quit(enter, M+1))
  801.                     restart = TRUE;
  802.                 else
  803.                    {
  804.                     if ((cptr1 = strstr(enter, "${ARCHTYPE}")) != NULL ||
  805.                                             (cptr1 = strstr(enter, "$ARCHTYPE")) != NULL)
  806.                        {
  807.                         for (cptr2 = &(enter[0]), cptr3 = &(dir[0]);
  808.                                                 cptr2 != cptr1; *(cptr3++) = *(cptr2++));
  809.                         for (cptr1 = &(arch[0]); *cptr1 != '\0'; *(cptr3++) = *(cptr1++));
  810.                         for (; *cptr2 != '/'; cptr2++);
  811.                         for (; *cptr2 != '\0'; *(cptr3++) = *(cptr2++));
  812.                         *cptr3 = '\0';
  813.                        }
  814.                     else
  815.                         (void) strcpy(dir, enter);
  816.                     if (stat(dir, &buf1) != 0 || ! S_ISREG(buf1.st_mode))
  817.                        {
  818.                         (void) fprintf(stderr,
  819.                             "\n        The file: %s\n%s", dir, messages[15]);
  820.                             (void) fprintf(stderr, "%d%s", M+1, messages[16]);
  821.                         get_line(enter);
  822.                         if (enter[0] =='Q' || enter[0] == 'q')
  823.                             return(0);
  824.                         else
  825.                             if (enter[0] =='R' || enter[0] == 'r')
  826.                                 restart = TRUE;
  827.                        }
  828.                     else
  829.                        {
  830.                         (void) strcpy(sim2loc, enter);
  831.                         break;
  832.                        }
  833.                    }
  834.                 if (restart)
  835.                     break;
  836.                }
  837.             if (restart)
  838.                 continue;
  839.             else
  840.                 sim2 = TRUE;
  841.            }
  842.  
  843.         if (machines[M].rsh == 'T')
  844.            {
  845.             machines[M].rmt_user[0] = '\0';
  846.             (void) fprintf(stderr, "%s%s", messages[18], machines[M].name);
  847.             (void) fprintf(stderr, "%s%s%s", messages[19],
  848.                                             machines[M].name, messages[20]);
  849.             (void) fprintf(stderr, "%s%s", machines[M].name, messages[21]);
  850.             switch (get_yn(M+1))
  851.                {
  852.                 case -1:
  853.                     return(0);
  854.                     break;
  855.                 case 0:
  856.                     continue;
  857.                     break;
  858.                 case 1:
  859.                     machines[M].run ='T';
  860.                     break;
  861.                 case 2:
  862.                     machines[M].run ='F';
  863.                     machines[M].rsh ='F';
  864.                     machines[M].rcp ='F';
  865.                     break;
  866.                }
  867.  
  868.             if (machines[M].run == 'T')
  869.                {
  870.                 (void) fprintf(stderr,
  871.     "\n\n        What is the address of %s%s", machines[M].name, messages[17]);
  872.                 if (get_line_quit(enter, M+1))
  873.                     continue;
  874.                 for (I = 0; I < M; I++)
  875.                     if (strcmp(enter, machines[I].address) == 0)
  876.                         break;
  877.                 if (I < M)
  878.                    {
  879.                     (void) fprintf(stderr, "%s%s%s%s%s", messages[69],
  880.                                         machines[M].name, messages[70],
  881.                                         machines[I].name, messages[71]);
  882.                     get_line(enter);
  883.                     if (enter[0] == 'Q' || enter[0] == 'q')
  884.                         exit(0);
  885.                     continue;
  886.                    }
  887.                 (void) strcpy(machines[M].address, enter);
  888.                 if (machines[M].type == '2' || machines[M].type == '8')
  889.                    {
  890.                     (void) fprintf(stderr, "%s%s%s\n\n",
  891.                                     messages[22], machines[M].name, messages[74]);
  892.                     switch (get_yn(M+1))
  893.                        {
  894.                         case -1:
  895.                             return(0);
  896.                             break;
  897.                          case 0:
  898.                             continue;
  899.                             break;
  900.                          case 1:
  901.                             machines[M].xmt = TRUE;
  902.                                 machines[M].rcp = 'F';
  903.                             machines[M].directory[0] = '.';
  904.                             break;
  905.                          case 2:
  906.                             machines[M].xmt = FALSE;
  907.                             machines[M].home = FALSE;
  908.                             machines[M].rcp = 'T';
  909.                              break;
  910.                        }
  911.  
  912.                     if (machines[M].xmt)
  913.                        {
  914.                         (void) fprintf(stderr, "%s%s?\n\n",
  915.                                             messages[23],  machines[M].name);
  916.                         switch (get_yn(M+1))
  917.                            {
  918.                             case -1:
  919.                                 return(0);
  920.                                 break;
  921.                              case 0:
  922.                                 continue;
  923.                                 break;
  924.                              case 1:
  925.                                 machines[M].home = TRUE;
  926.                                 break;
  927.                              case 2:
  928.                                 machines[M].home = FALSE;
  929.                                  break;
  930.                            }
  931.                        }
  932.                    }
  933.                }
  934.             else
  935.                 (void) strcpy(machines[M].address, "none");
  936.            }
  937.         (void) fprintf(stderr,
  938. "\n\n        What is the largest number of dimensions that %s supports?\n\n",
  939.                                                         machines[M].name);
  940.             for(;;)
  941.                {
  942.                 restart = FALSE;
  943.                 (void) fprintf(stderr, "             ==> ");
  944.                 if(get_line_quit(enter, M+1))
  945.                    {
  946.                     restart = TRUE;
  947.                     break;
  948.                    }
  949.                 if (! isdigit(enter[0]) ||
  950.                                 (tempi = (int) enter[0] - (int) '0') > 7  ||
  951.                                             tempi == 0 || enter[1] != '\0')
  952.                    {
  953.                     (void) fprintf(stderr,
  954.          "\n        (You should enter a valid number between 1 and 7.)\n\n");
  955.                     continue;
  956.                    }
  957.                 else
  958.                    {
  959.                     machines[M].maxdim = machines[M].dim = tempi;
  960.                     break;
  961.                    }
  962.                }
  963.             if (restart) continue;
  964.  
  965.         if (machines[M].run == 'T')
  966.            {
  967.             if (machines[M].rsh == 'T')
  968.                {
  969.                 if (machines[M].xmt)
  970.                    {
  971.                     (void) fprintf(stderr, "%s        %s.  Is %s\n%s",
  972.                                                 messages[25], machines[M].name,
  973.                                                         current, messages[26]);
  974.                     switch (get_yn(M+1))
  975.                        {
  976.                         case -1:
  977.                             return(0);
  978.                             break;
  979.                          case 0:
  980.                             continue;
  981.                             break;
  982.                          case 1:
  983.                             machines[M].rmt_install = 'L';
  984.                             (void) strcpy(machines[M].lcl_directory, current);
  985.                             (void) fprintf(stderr, "\n\n%s%s%s%s\n\n%s",
  986.                                         messages[63], machines[M].name,
  987.                                         messages[64], machines[M].lcl_directory,
  988.                                                                 messages[65]);
  989.                             if (get_line_quit(enter, M+1))
  990.                                continue;
  991.                             (void) strcpy(machines[M].rmt_directory, enter);
  992.                             break;
  993.                          case 2:
  994.                             machines[M].rmt_install = 'R';
  995.                             (void) fprintf(stderr, "%s%s%s",
  996.                                                 messages[27], user, messages[28]);
  997.                             switch (get_yn(M+1))
  998.                                {
  999.                                 case -1:
  1000.                                     return(0);
  1001.                                     break;
  1002.                                 case 0:
  1003.                                     continue;
  1004.                                     break;
  1005.                                 case 1:
  1006.                                     machines[M].rmt_install = 'L';
  1007.                                     (void) fprintf(stderr, "%s", messages[29]);
  1008.                                     if (get_line_quit(enter, M+1))
  1009.                                         continue;
  1010.                                     (void) strcpy(machines[M].lcl_directory,
  1011.                                                                         enter);
  1012.                                     (void) fprintf(stderr, "\n\n%s%s%s%s\n\n%s",
  1013.                                           messages[63], machines[M].name,
  1014.                                           messages[64], machines[M].lcl_directory,
  1015.                                                                   messages[65]);
  1016.                                     if (get_line_quit(enter, M+1))
  1017.                                        continue;
  1018.                                     (void) strcpy(machines[M].rmt_directory,
  1019.                                                                         enter);
  1020.                                     break;
  1021.                                 case 2:
  1022.                                     break;
  1023.                                }
  1024.                         break;
  1025.                        }
  1026.                    }
  1027.                 else
  1028.                     machines[M].rmt_install = 'R';
  1029.                 if (machines[M].rmt_install == 'R')
  1030.                    {
  1031.                     (void) fprintf(stderr,
  1032.     "\n\n        What is the full path name of the directory on %s\n%s",
  1033.                                                 machines[M].name, messages[30]);
  1034.                     (void) fprintf(stderr,
  1035.                                 "%s or\n        a user that trusts %s on %s%s",
  1036.                                     user, user, machines[M].name, messages[31]);
  1037.                     if (get_line_quit(enter, M+1))
  1038.                         continue;
  1039.                     if (strcmp(enter, "none") == 0)
  1040.                        {
  1041.                         machines[M].rmt_install = 'M';
  1042.                         (void) sprintf(machines[M].lcl_directory, "%s/%s",
  1043.                                                     current, machines[M].name);
  1044.                         (void) fprintf(stderr, "%s%s%s%s%s",
  1045.                                     messages[53], machines[M].name, messages[54],
  1046.                                                 machines[M].name, messages[55]);
  1047.                         if (get_line_quit(enter, M+1))
  1048.                         continue;
  1049.                        }
  1050.                     (void) strcpy(machines[M].rmt_directory, enter);
  1051.                    }
  1052.                 if (machines[M].rmt_install == 'R' || machines[M].rmt_install == 'L')
  1053.                    {
  1054.                     if (machines[M].rmt_install == 'L')
  1055.                         (void) strcpy(machines[M].lcl_directory, current);
  1056.                     else
  1057.                         (void) sprintf(machines[M].lcl_directory, "%s/%s",
  1058.                                                     current, machines[M].name);
  1059.                     (void) fprintf(stderr, "\n\n        Please be patient,\n");
  1060.                     (void) fprintf(stderr,
  1061.                 "            Checking with the parallel machine %s . . . \n",
  1062.                                                             machines[M].name);
  1063.                     if (pipe(fdes))
  1064.                        {
  1065.                         (void) fprintf(stderr,
  1066.            "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
  1067.                         exit(1);
  1068.                        }
  1069.                     if (fork())
  1070.                        {
  1071.                         (void) wait(NULL);
  1072.                         tempi = read(fdes[0], line, MAXLINESIZE);
  1073.                         line[tempi] = '\0';
  1074.                         (void) close(fdes[0]);
  1075.                         (void) close(fdes[1]);
  1076.                        }
  1077.                     else
  1078.                        {
  1079.                         (void) dup2(fdes[1], 1);
  1080.                         (void) dup2(fdes[1], 2);
  1081.                         (void) execlp("rsh", "rsh", machines[M].address, "pwd", 0);
  1082.                        }
  1083.                     choice = 0;
  1084.                     switch (line[0])
  1085.                        {
  1086.                         case 'L':
  1087.                             if (strncmp(line, "Login incorrect", 15) == 0)
  1088.                                 choice = 3;
  1089.                             break;
  1090.                         case 'P':
  1091.                             if (strncmp(line, "Permission denied", 17) == 0)
  1092.                                 choice = 2;
  1093.                             break;
  1094.                         case '/':
  1095.                             choice = 5;
  1096.                             break;
  1097.                         default:
  1098.                             if ((cptr1 = strchr(line, ':')) != NULL &&
  1099.                                         strncmp(cptr1, ": unknown host", 14) == 0)
  1100.                                 choice = 1;
  1101.                             break;
  1102.                        }
  1103.                     if (choice == 5)
  1104.                        {
  1105.                         (void) fprintf(stderr,
  1106.                 "            . . . still checking with %s . . .\n",
  1107.                                                             machines[M].name);
  1108.                         (void) sprintf(dir, "%s/_D_TEST",
  1109.                                                     machines[M].rmt_directory);
  1110.                         if (pipe(fdes))
  1111.                            {
  1112.                             (void) fprintf(stderr,
  1113.           "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
  1114.                             exit(1);
  1115.                            }
  1116.                         if (fork())
  1117.                            {
  1118.                             (void) wait(NULL);
  1119.                             line[0] = '\0';
  1120.                             (void) fcntl(fdes[0], F_SETFL, O_NDELAY);
  1121.                             tempi = read(fdes[0], line, MAXLINESIZE);
  1122.                             line[tempi] = '\0';
  1123.                             (void) close(fdes[0]);
  1124.                             (void) close(fdes[1]);
  1125.                            }
  1126.                         else
  1127.                            {
  1128.                             (void) dup2(fdes[1], 1);
  1129.                             (void) dup2(fdes[1], 2);
  1130.                             (void) execlp("rsh", "rsh",
  1131.                                         machines[M].address, "touch", dir, 0);
  1132.                            }
  1133.                         if (strlen(line) > 0)
  1134.                             choice = 4;
  1135.                         else
  1136.                            {
  1137.                             (void) fprintf(stderr,
  1138.                             "            . . . one last check . . .\n");
  1139.                             if (fork())
  1140.                                 (void) wait(NULL);
  1141.                             else
  1142.                                 (void) execlp("rsh", "rsh",
  1143.                                             machines[M].address, "rm", dir, 0);
  1144.                            }
  1145.                        }
  1146.                     switch (choice)
  1147.                        {
  1148.                         case 0:
  1149.                             (void) fprintf(stderr,
  1150.                 "        DINO is unable to access %s with \"rsh\" (which\n",
  1151.                                                                machines[M].name);
  1152.                             (void) fprintf(stderr,
  1153.                 "        returned the error --> %s\n", line);
  1154.                             break;
  1155.                         case 1:
  1156.                             (void) fprintf(stderr,
  1157.    "        The host table on this machine reports that there is no parallel\n");
  1158.                             (void) fprintf(stderr,
  1159.                                 "        machine with the address \"%s\".\n\n",
  1160.                                                             machines[M].address);
  1161.                             break;
  1162.                         case 2:
  1163.                             (void) fprintf(stderr,
  1164.           "        It appears that the permissions in %s's \".rhosts\" file on\n",
  1165.                                                                     user);
  1166.                             (void) fprintf(stderr,
  1167.                 "        %s are not set correctly.\n\n", machines[M].name);
  1168.                             break;
  1169.                         case 3:
  1170.                             (void) fprintf(stderr,
  1171.                         "        There appears to be no login for %s on %s.\n\n",
  1172.                                                         user, machines[M].name);
  1173.                             break;
  1174.                         case 4:
  1175.                             (void) fprintf(stderr,
  1176.           "        It appears that %s does not have write permission in\n", user);
  1177.                             (void) fprintf(stderr,
  1178.           "        %s on %s\n\n", machines[M].rmt_directory, machines[M].name);
  1179.                             break;
  1180.                         case 5:
  1181.                             break;
  1182.                        }
  1183.                     if (choice < 2)
  1184.                        {
  1185.                         (void) fprintf(stderr,
  1186.   "        DINO will not be able to install the back end on %s%s%d over ==> ",
  1187.                                             machines[M].name, messages[32], M+1);
  1188.                         get_line(enter);
  1189.                         if (enter[0] =='Q' || enter[0] == 'q')
  1190.                             return(0);
  1191.                         if (enter[0] =='M' || enter[0] == 'm')
  1192.                             machines[M].rmt_install = 'M';
  1193.                        else
  1194.                             continue;
  1195.                        }
  1196.                     if (choice < 5 && machines[M].rmt_install != 'M')
  1197.                        {
  1198.                         (void) fprintf(stderr,
  1199.         "        Is there another user on %s that trusts %s (i.e. that user's\n",
  1200.                                                         machines[M].name, user);
  1201.                         (void) fprintf(stderr,
  1202.     "        \".rhosts\" file has %s in it) and that is allowed to write in\n",
  1203.                                                                         user);
  1204.                         (void) fprintf(stderr,
  1205.                 "        the directory where you want DINO installed?\n\n");
  1206.                         switch (get_yn(M+1))
  1207.                            {
  1208.                             case -1:
  1209.                                 return(0);
  1210.                                 break;
  1211.                             case 0:
  1212.                                 continue;
  1213.                                 break;
  1214.                             case 1:
  1215.                                 (void) fprintf(stderr,
  1216.                             "\n        Please enter the name of that user ==>");
  1217.                                 if (get_line_quit(enter, M+1))
  1218.                                     continue;
  1219.                                 (void) fprintf(stderr,
  1220.                                             "\n        Please be patient,\n");
  1221.                                 (void) fprintf(stderr,
  1222.         "\n            Checking (again) with the parallel machine %s . . . \n",
  1223.                                                             machines[M].name);
  1224.                                 if (pipe(fdes))
  1225.                                    {
  1226.                                     (void) fprintf(stderr,
  1227.           "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
  1228.                                     exit(1);
  1229.                                    }
  1230.                                 if (fork())
  1231.                                    {
  1232.                                     (void) wait(NULL);
  1233.                                     tempi = read(fdes[0], line, MAXLINESIZE);
  1234.                                     line[tempi] = '\0';
  1235.                                     (void) close(fdes[0]);
  1236.                                     (void) close(fdes[1]);
  1237.                                    }
  1238.                                 else
  1239.                                    {
  1240.                                     (void) dup2(fdes[1], 1);
  1241.                                     (void) dup2(fdes[1], 2);
  1242.                                     (void) execlp("rsh", "rsh", machines[M].address,
  1243.                                                         "-l", enter, "pwd", 0);
  1244.                                    }
  1245.                                 choice = 0;
  1246.                                 switch (line[0])
  1247.                                    {
  1248.                                     case 'L':
  1249.                                         if (strncmp(line, "Login incorrect", 15)
  1250.                                                                         == 0)
  1251.                                             choice = 3;
  1252.                                         break;
  1253.                                     case 'P':
  1254.                                         if (strncmp(line, "Permission denied",
  1255.                                                                     17) == 0)
  1256.                                             choice = 2;
  1257.                                         break;
  1258.                                     case '/':
  1259.                                         choice = 5;
  1260.                                         break;
  1261.                                     default:
  1262.                                         if ((cptr1 = strchr(line, ':')) != NULL
  1263.                                 && strncmp(cptr1, ": unknown host", 14) == 0)
  1264.                                             choice = 1;
  1265.                                         break;
  1266.                                    }
  1267.                                 if (choice == 5)
  1268.                                    {
  1269.                                     if (pipe(fdes))
  1270.                                        {
  1271.                                         (void) fprintf(stderr,
  1272.           "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
  1273.                                         exit(1);
  1274.                                        }
  1275.                                     if (fork())
  1276.                                        {
  1277.                                         (void) wait(NULL);
  1278.                                         tempi = read(fdes[0], line, MAXLINESIZE);
  1279.                                         line[tempi] = '\0';
  1280.                                         (void) close(fdes[0]);
  1281.                                         (void) close(fdes[1]);
  1282.                                        }
  1283.                                     else
  1284.                                        {
  1285.                                         (void) dup2(fdes[1], 1);
  1286.                                         (void) dup2(fdes[1], 2);
  1287.                                         (void) execlp("rsh", "rsh",
  1288.                                                         machines[M].address,
  1289.                                                 "-l", enter, "touch", dir, 0);
  1290.                                        }
  1291.                                     if (strlen(line) > 0)
  1292.                                         choice = 4;
  1293.                                     else
  1294.                                        {
  1295.                                         if (fork())
  1296.                                             (void) wait(NULL);
  1297.                                         else
  1298.                                             (void) execlp("rsh", "rsh",
  1299.                                                     machines[M].address, "-l",
  1300.                                                     enter, "rm", dir, 0);
  1301.                                        }
  1302.                                    }
  1303.                                 switch (choice)
  1304.                                    {
  1305.                                     case 0:
  1306.                                         (void) fprintf(stderr,
  1307.                     "        DINO is unable to access %s with \"rsh\" (which\n",
  1308.                                                               machines[M].name);
  1309.                                         (void) fprintf(stderr,
  1310.                             "        returned the error --> %s\n", line);
  1311.                                         break;
  1312.                                     case 1:
  1313.                                         (void) fprintf(stderr,
  1314.    "        The host table on this machine reports that there is no parallel\n");
  1315.                                         (void) fprintf(stderr,
  1316.                                 "        machine with the address \"%s\".\n\n",
  1317.                                                             machines[M].address);
  1318.                                         break;
  1319.                                     case 2:
  1320.                                         (void) fprintf(stderr,
  1321.         "        It appears that the permissions in %s's \".rhosts\" file on\n",
  1322.                                                                          enter);
  1323.                                         (void) fprintf(stderr,
  1324.                     "        %s are not set correctly.\n\n", machines[M].name);
  1325.                                         break;
  1326.                                     case 3:
  1327.                                         (void) fprintf(stderr,
  1328.                        "        There appears to be no login for %s on %s.\n\n",
  1329.                                                          enter, machines[M].name);
  1330.                                         break;
  1331.                                     case 4:
  1332.                                         (void) fprintf(stderr,
  1333.         "        It appears that %s does not have write permission in\n", enter);
  1334.                                         (void) fprintf(stderr,
  1335.             "        %s on %s\n\n", machines[M].rmt_directory, machines[M].name);
  1336.                                         break;
  1337.                                     case 5:
  1338.                                         break;
  1339.                                    }
  1340.                                 if (choice < 5)
  1341.                                    {
  1342.                                     (void) fprintf(stderr,
  1343.       "        DINO will not be able to install the back end on %s%s%d over ==> ",
  1344.                                             machines[M].name, messages[32], M+1);
  1345.                                     get_line(enter);
  1346.                                     if (enter[0] =='Q' || enter[0] == 'q')
  1347.                                         return(0);
  1348.                                     if (enter[0] =='M' || enter[0] == 'm')
  1349.                                         machines[M].rmt_install = 'M';
  1350.                                    else
  1351.                                         continue;
  1352.                                    }
  1353.                                 else
  1354.                                     (void) strcpy(machines[M].rmt_user, enter);
  1355.                                 break;
  1356.                             case 2:
  1357.                                 (void) fprintf(stderr, "%s%d over again ==>",
  1358.                                                         messages[33], M+1);
  1359.                                 get_line(enter);
  1360.                                 if (enter[0] =='Q' || enter[0] == 'q')
  1361.                                     return(0);
  1362.                                 if (enter[0] =='M' || enter[0] == 'm')
  1363.                                     machines[M].rmt_install = 'M';
  1364.                                    else
  1365.                                     continue;
  1366.                                 break;
  1367.                            }
  1368.                        }
  1369.                     (void) fprintf(stderr,
  1370.     "            . . . %s appears to be set up correctly for installation.\n\n",
  1371.                                                             machines[M].name);
  1372.                    }
  1373.                }
  1374.             else
  1375.                {
  1376.                 machines[M].rmt_install = 'L';
  1377.                 (void) strcpy(machines[M].rmt_directory, current);
  1378.                 (void) sprintf(machines[M].lcl_directory, "%s/%s",
  1379.                                                     current, machines[M].name);
  1380.                }
  1381.            }
  1382.         else
  1383.            {
  1384.             machines[M].rmt_install = 'N';
  1385.             (void) strcpy(machines[M].rmt_directory, "Not Installed");
  1386.             (void) strcpy(machines[M].lcl_directory, "Not Installed");
  1387.            }
  1388.  
  1389.         (void) fprintf(stderr,
  1390.             "\n\n        The configuration for %s is:\n\n", machines[M].name);
  1391.         (void) fprintf(stderr, "             - its type is ");
  1392.         switch (machines[M].type)
  1393.            {
  1394.             case 's':
  1395.                 (void) fprintf(stderr, "an Intel iPSC1 simulator\n");
  1396.                 break;
  1397.             case 'S':
  1398.                 (void) fprintf(stderr, "an Intel iPSC2 simulator\n");
  1399.                 break;
  1400.             case '1':
  1401.                 (void) fprintf(stderr, "an Intel iPSC1\n");
  1402.                 break;
  1403.             case '2':
  1404.                 (void) fprintf(stderr, "an Intel iPSC2\n");
  1405.                 break;
  1406.             case '8':
  1407.                 (void) fprintf(stderr,
  1408.                                  "an Intel i860 version of the iPSC2\n");
  1409.                 break;
  1410.             case 'G':
  1411.                 (void) fprintf(stderr, "a distributed sun machine\n");
  1412.                 break;
  1413.            }
  1414.         if (machines[M].address[0] =='.')
  1415.            {
  1416.             (void) fprintf(stderr,
  1417.     "             - its address is that it uses the same machine for the\n");
  1418.             (void) fprintf(stderr,
  1419.     "                       parallel machine as it does for the compiler\n");
  1420.            }
  1421.         else
  1422.             (void) fprintf(stderr, "             - its address is %s\n",
  1423.                                                         machines[M].address);
  1424.         (void) fprintf(stderr,
  1425.     "             - its user on the parallel machine will be the same\n");
  1426.         (void) fprintf(stderr,
  1427.         "                                        as the user on the sun\n");
  1428.         if (machines[M].directory[0] == '~')
  1429.            {
  1430.             (void) fprintf(stderr,
  1431.     "             - its directory on the parallel machine will be the home\n");
  1432.             (void) fprintf(stderr,
  1433.     "                                   directory of the user on the sun\n");
  1434.            }
  1435.         else
  1436.            {
  1437.             (void) fprintf(stderr,
  1438.     "             - its directory on the parallel machine will be the same\n");
  1439.             (void) fprintf(stderr,
  1440.     "                                as the current directory on the sun\n");
  1441.            }
  1442.         (void) fprintf(stderr,
  1443.     "             - it is configured for %d dimensions\n", machines[M].maxdim);
  1444.         if (machines[M].run =='T')
  1445.            {
  1446.             (void) fprintf(stderr,
  1447.                 "             - DINO will automatically run the second \n");
  1448.             (void) fprintf(stderr,
  1449.                     "                       half of the DINO compilation\n");
  1450.            }
  1451.         else
  1452.            {
  1453.             (void) fprintf(stderr,
  1454.                     "             - DINO will stop after the intermediate\n");
  1455.             (void) fprintf(stderr,
  1456.                             "                       C files are generated\n");
  1457.            }
  1458.         if (machines[M].run =='T')
  1459.            {
  1460.             if (machines[M].rsh =='T')
  1461.                {
  1462.                 if (machines[M].rcp =='T')
  1463.                     (void) fprintf(stderr,
  1464. "             - DINO will copy files to %s with \"rcp\"\n", machines[M].name);
  1465.                 else
  1466.                     (void) fprintf(stderr,
  1467. "             - DINO will not need to copy files to %s\n", machines[M].name);
  1468.                 if (machines[M].xmt)
  1469.                    {
  1470.                     (void) fprintf(stderr,
  1471.         "                       (%s shares its filesystem with the suns,\n");
  1472.                     if (machines[M].home)
  1473.                         (void) fprintf(stderr,
  1474.         "                       and the home directories are the same)\n");
  1475.                     else
  1476.                         (void) fprintf(stderr,
  1477.         "                       but the home directories are different)\n");
  1478.                    }
  1479.                 else
  1480.                     (void) fprintf(stderr,
  1481.     "                       (%s's filesystem is seperate from the suns)\n");
  1482.                 (void) fprintf(stderr,
  1483.                 "             - DINO will start the second half of DINO\n");
  1484.                 (void) fprintf(stderr,
  1485.             "                       on %s with \"rsh\"\n", machines[M].name);
  1486.                }
  1487.             else
  1488.                {
  1489.                 (void) fprintf(stderr,
  1490.                 "             - DINO will start the second half of DINO\n");
  1491.                 (void) fprintf(stderr,
  1492.                     "                       on the sun with a local call\n");
  1493.                }
  1494.            }
  1495.         if (machines[M].type == 's')
  1496.            {
  1497.             (void) fprintf(stderr,
  1498. "             - The iPSC1 simulator library files can be found at\n");
  1499.             (void) fprintf(stderr,
  1500. "                   %s\n", sim1loc);
  1501.            }
  1502.         if (machines[M].type == 'S')
  1503.            {
  1504.             (void) fprintf(stderr,
  1505. "             - The iPSC2 simulator library files can be found at\n");
  1506.             (void) fprintf(stderr,
  1507. "                   %s\n", sim2loc);
  1508.            }
  1509.         switch (machines[M].rmt_install)
  1510.            {
  1511.             case 'N':
  1512.                 (void) fprintf(stderr,
  1513. "             - DINO will not attempt to install the back end\n");
  1514.                 break;
  1515.             case 'M':
  1516.                 (void) fprintf(stderr,
  1517. "             - DINO will create a local directory named \"%s\"\n",
  1518.                                                             machines[M].name);
  1519.                 (void) fprintf(stderr,
  1520. "               in the current directory (%s).\n", current);
  1521.                 (void) fprintf(stderr,
  1522. "               You will have to move the contents of that directory to the\n");
  1523.                 (void) fprintf(stderr,
  1524. "               directory \"%s\" on %s\n",
  1525.                                 machines[M].rmt_directory, machines[M].name);
  1526.                 (void) fprintf(stderr,
  1527. "               and finish the installation there.\n");
  1528.                 break;
  1529.             case 'L':
  1530.                 (void) fprintf(stderr,
  1531. "             - DINO will attempt to install the back end for %s in\n",
  1532.                                                             machines[M].name);
  1533.                 (void) fprintf(stderr,
  1534. "               the directory %s\n", machines[M].lcl_directory);
  1535.                 if (machines[M].rsh == 'T')
  1536.                    {
  1537.                     (void) fprintf(stderr,
  1538. "                 (because the directory is cross-mounted to %s\n",
  1539.                                                             machines[M].name);
  1540.                     (void) fprintf(stderr,
  1541. "                 where its path is %s).\n", machines[M].rmt_directory);
  1542.                    }
  1543.                 else
  1544.                     (void) fprintf(stderr,
  1545. "                 (because %s is on this machine).\n",  machines[M].name);
  1546.                 break;
  1547.             case 'R':
  1548.                 (void) fprintf(stderr,
  1549. "             - DINO will attempt to install the back end directly on %s\n",
  1550.                                                             machines[M].name);
  1551.                 (void) fprintf(stderr,
  1552. "               in the directory %s\n", machines[M].rmt_directory);
  1553.                 break;
  1554.            }
  1555.  
  1556.  
  1557.         (void) fprintf(stderr, "\n        Record this configuration?\n\n");
  1558.         for(;;)
  1559.            {
  1560.             (void) fprintf(stderr, "             (Y/N) ==> ");
  1561.             get_line(enter);
  1562.             if (enter[0] != 'Y' && enter[0] != 'y' &&
  1563.                                         enter[0] != 'N' && enter[0] != 'n')
  1564.                {
  1565.                 (void) fprintf(stderr,
  1566.               "\n        (You should enter either a \"Y\" or a \"N\".)\n\n");
  1567.                 continue;
  1568.                }
  1569.             else
  1570.                {
  1571.                 if (enter[0] == 'Y' || enter[0] == 'y')
  1572.                     M++;
  1573.                 break;
  1574.                }
  1575.            }
  1576.  
  1577.         done = TRUE;
  1578.         if (M < (MAXMACHINES))
  1579.            {
  1580.             (void) fprintf(stderr,
  1581.                             "\n\n        Configure another parallel machine?\n\n");
  1582.             for(;;)
  1583.                {
  1584.                 (void) fprintf(stderr, "             (Y/N) ==> ");
  1585.                 get_line(enter);
  1586.                 if (enter[0] != 'Y' && enter[0] != 'y' &&
  1587.                                               enter[0] != 'N' && enter[0] != 'n')
  1588.                    {
  1589.                     (void) fprintf(stderr,
  1590.                   "\n        (You should enter either a \"Y\" or a \"N\".)\n\n");
  1591.                     continue;
  1592.                    }
  1593.                 else
  1594.                    {
  1595.                     if (enter[0] == 'Y' || enter[0] == 'y')
  1596.                         done = FALSE;
  1597.                     break;
  1598.                    }
  1599.                }
  1600.            }
  1601.         else
  1602.             (void) fprintf(stderr,
  1603. "\n\n        You have defined the largest number of parallel machines allowed.\n");
  1604.         if (done) break;
  1605.        }
  1606.     if (M == 0)
  1607.        {
  1608.         (void) fprintf(stderr,
  1609.        "\n    You have not defined any parallel machines.\n    Bye bye.\n");
  1610.         return(0);
  1611.        }
  1612.     (void) fprintf(stderr,
  1613.              "\n\n    The following parallel machines have been defined:\n");
  1614.     for (I=0; I < M; I++)
  1615.         (void) fprintf(stderr,"        %s\n", machines[I].name);
  1616.     if (M > 1)
  1617.        {
  1618.         (void) fprintf(stderr, "%s", messages[24]);
  1619.         for(;;)
  1620.            {
  1621.             (void) fprintf(stderr, "       Enter a machine name ==> ");
  1622.             get_line(enter);
  1623.             for (I = 0; I < M; I++)
  1624.                 if (strcmp(enter, machines[I].name) == 0)
  1625.                    {
  1626.                     dfalt = I;
  1627.                     break;
  1628.                    }
  1629.             if (I < M)
  1630.                break;
  1631.             (void) fprintf(stderr,
  1632.                     "\n    You have not entered a valid machine name.\n\n");
  1633.            }
  1634.        }
  1635.     (void) fprintf(stderr,
  1636.               "\n\n    Proceed with the installation of %s?\n\n",
  1637.                                             (M>1)?"these machines":"this machine");
  1638.     for(;;)
  1639.            {
  1640.             (void) fprintf(stderr, "             (Y/N) ==> ");
  1641.             get_line(enter);
  1642.             if (enter[0] != 'Y' && enter[0] != 'y' &&
  1643.                                           enter[0] != 'N' && enter[0] != 'n')
  1644.                {
  1645.                 (void) fprintf(stderr,
  1646.               "\n        (You should enter either a \"Y\" or a \"N\".)\n\n");
  1647.                 continue;
  1648.                }
  1649.             else
  1650.                {
  1651.                 if (enter[0] == 'N' || enter[0] == 'n')
  1652.                     return(0);
  1653.                 else
  1654.                     break;
  1655.                }
  1656.            }
  1657.          }
  1658.  
  1659.         /* OK, we are done asking questions.  Now install the machines
  1660.                     that have been defined in the first half of the program. */
  1661.  
  1662.         /* First, make sure that the general directory structure
  1663.                     for the    front end is correct and the various
  1664.                     shell files and examples are installed: */
  1665.         
  1666.     (void) fprintf(stderr, "\n\n    Checking directory structure . . .\n");
  1667.     maked("bin", (char *) NULL, (char *) NULL);
  1668.     maked(arch, "bin", (char *) NULL);
  1669.     maked("bin/local", (char *) NULL, (char *) NULL);
  1670.     copy("source/shell", "dino.special.example", "bin/local", 0);
  1671.     copy("source/shell", "dino.init.example", "bin/local", 0);
  1672.     (void) sprintf(dir, "bin/%s", arch);
  1673.     copy("source/shell", "dino", dir, 0);
  1674.     maked("lib", (char *) NULL, (char *) NULL);
  1675.     maked(arch, "lib", (char *) NULL);
  1676.     (void) fprintf(stderr, "\n    Directory structure correct\n");
  1677.  
  1678.         /* If this is an initial installation,
  1679.                                 create the "dino.init" file. */
  1680.  
  1681.      if (! update)
  1682.         {
  1683.         (void) fprintf(stderr,
  1684. "\n    Writing a new configuration file (dino.init). . .\n");
  1685.         if ((init = fopen("bin/local/dino.init", "w")) == NULL)
  1686.            {
  1687.             (void) fprintf(stderr,
  1688.           "\n\n\t\tError opening %s\n", "bin/local/dino.init");
  1689.             perror("\t\t\t");
  1690.             (void) fprintf(stderr,
  1691.           "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
  1692.             exit(1);
  1693.            }
  1694.  
  1695.         if ((input = fopen("source/install/DI1", "r")) == NULL)
  1696.            {
  1697.             (void) fprintf(stderr,
  1698.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1699.                                                                         "DI1");
  1700.             exit(1);
  1701.            }
  1702.         while (! feof(input))
  1703.             if (fgets(line, MAXLINESIZE, input) != NULL)
  1704.                 (void) fputs(line, init);
  1705.         (void) fclose(input);
  1706.  
  1707.         (void) fprintf(init, "Dhome=%s\n", current);
  1708.  
  1709.         if ((input = fopen("source/install/DI2", "r")) == NULL)
  1710.            {
  1711.             (void) fprintf(stderr,
  1712.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1713.                                                                         "DI2");
  1714.             exit(1);
  1715.            }
  1716.         while (! feof(input))
  1717.             if (fgets(line, MAXLINESIZE, input) != NULL)
  1718.                 (void) fputs(line, init);
  1719.         (void) fclose(input);
  1720.  
  1721.         (void) fprintf(init, "Dmachs=\"%s %s %s %s %c%d%c%c%c%c%d",
  1722.                                     machines[0].name, machines[0].address,
  1723.                                     machines[0].user, machines[0].directory,
  1724.                                     machines[0].type, machines[0].maxdim,
  1725.                                     machines[0].rcp, machines[0].rsh,
  1726.                                     machines[0].run, machines[0].date,
  1727.                                     machines[0].dim);
  1728.         for (I = 1; I < M; I++)
  1729.             (void) fprintf(init, " \\\n        %s %s %s %s %c%d%c%c%c%c%d",
  1730.                                     machines[I].name, machines[I].address,
  1731.                                     machines[I].user, machines[I].directory,
  1732.                                     machines[I].type, machines[I].maxdim,
  1733.                                     machines[I].rcp, machines[I].rsh,
  1734.                                     machines[I].run, machines[I].date,
  1735.                                     machines[I].dim);
  1736.         (void) fprintf(init, "\"\n");
  1737.  
  1738.         if ((input = fopen("source/install/DI3", "r")) == NULL)
  1739.            {
  1740.             (void) fprintf(stderr,
  1741.       "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1742.                                                                     "DI3");
  1743.             exit(1);
  1744.            }
  1745.         while (! feof(input))
  1746.             if (fgets(line, MAXLINESIZE, input) != NULL)
  1747.                 (void) fputs(line, init);
  1748.         (void) fclose(input);
  1749.  
  1750.         for (I = 0; I < M; I++)
  1751.            {
  1752.             (void) fprintf(init, "## %s = (%c) %s\n", machines[I].name,
  1753.                         machines[I].rmt_install, machines[I].rmt_directory);
  1754.             if (machines[I].rmt_install == 'L')
  1755.                 (void) fprintf(init, "##           %s\n",
  1756.                                                     machines[I].lcl_directory);
  1757.            }
  1758.  
  1759.         if ((input = fopen("source/install/DI4", "r")) == NULL)
  1760.            {
  1761.             (void) fprintf(stderr,
  1762.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1763.                                                                         "DI4");
  1764.             exit(1);
  1765.            }
  1766.         while (! feof(input))
  1767.             if (fgets(line, MAXLINESIZE, input) != NULL)
  1768.                 (void) fputs(line, init);
  1769.         (void) fclose(input);
  1770.  
  1771.  
  1772.         (void) fprintf(init, "sDmachine=%s\n", machines[dfalt].name);
  1773.  
  1774.         if ((input = fopen("source/install/DI5", "r")) == NULL)
  1775.            {
  1776.             (void) fprintf(stderr,
  1777.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1778.                                                                          "DI5");
  1779.             exit(1);
  1780.            }
  1781.         while (! feof(input))
  1782.             if (fgets(line, MAXLINESIZE, input) != NULL)
  1783.                 (void) fputs(line, init);
  1784.         (void) fclose(input);
  1785.  
  1786.         (void) fprintf(init, "export Dhome Dmachs sDmachine\n");
  1787.  
  1788.         (void) fclose(init);
  1789.  
  1790.         (void) fprintf(stderr,
  1791.         "    Configuration file (dino.init) written.\n");
  1792.        }
  1793.  
  1794.          /* Create the link to dino.init.  We have to do this all the
  1795.             time because if we are doing a sun3/sun4 installation,
  1796.             we need two links, even though the second installation
  1797.                                             is treated as an update. */
  1798.  
  1799.     (void) sprintf(name, "%s/bin/local/dino.init", current);
  1800.     (void) sprintf(name2, "%s/bin/%s/dino.init", current, arch);
  1801.     (void) unlink(name2);
  1802.     if (symlink(name, name2) != 0)
  1803.        {
  1804.          (void) fprintf(stderr,
  1805.      "\n\nFATAL SYSTEM ERROR 10: Contact dino@cs.colorado.edu for help\n\n");
  1806.         exit(1);
  1807.        }
  1808.  
  1809.         /* If we are supposed to, generate the core of the DINO compiler. */
  1810.  
  1811.     if (source)
  1812.          {
  1813.         (void) fprintf(stderr,
  1814.             "    Generating the main portion of the DINO compiler\n");
  1815.         (void) fprintf(stderr,
  1816.         "         (please be patient, this is a lengthy process) . . .\n\n");
  1817.         if (fork())
  1818.            {
  1819.             (void) wait(&status);
  1820.             if (status)
  1821.                {
  1822.                 (void) fprintf(stderr, 
  1823.         "\n\n    Make failed for the main portion of the DINO compiler.\n\n");
  1824.                 (void) fprintf(stderr, 
  1825.                   "        Contact dino@cs.colorado.edu for help.\n\n");
  1826.                 return(0);
  1827.                }
  1828.            }
  1829.         else
  1830.            {
  1831.             (void) sprintf(name, "ARCHTYPE=%s", arch);
  1832.             (void) chdir("source/compiler");
  1833.             (void) execlp("make", "make", name, 0);
  1834.            }
  1835.        }
  1836.  
  1837.         /* Generate the user shell for the front end of the DINO compiler. */
  1838.  
  1839.     (void) fprintf(stderr,
  1840.         "\n    Generating the user shell for the DINO compiler . . .\n\n");
  1841.     if (fork())
  1842.        {
  1843.         (void) wait(&status);
  1844.         if (status)
  1845.            {
  1846.             (void) fprintf(stderr, 
  1847.             "\n\n    Make failed for the user shell for the DINO compiler.\n");
  1848.             (void) fprintf(stderr, 
  1849.                   "        Contact dino@cs.colorado.edu for help.\n\n");
  1850.             return(0);
  1851.            }
  1852.        }
  1853.     else
  1854.        {
  1855.          (void) sprintf(name, "ARCHTYPE=%s", arch);
  1856.         (void) chdir("source/shell");
  1857.         (void) execlp("make", "make", name, 0);
  1858.        }
  1859.  
  1860.         /* Find out if we have any backends that run on this machine.
  1861.                 If so, set an appropriate flag for those kinds that do. */
  1862.  
  1863.     sim1 = sim2 = grail = FALSE;
  1864.     for (I = 0; I < M; I++)
  1865.        {
  1866.         if (machines[I].rsh != 'T')
  1867.            {
  1868.             switch (machines[I].type)
  1869.                {
  1870.                  case 's':
  1871.                     sim1 = TRUE;
  1872.                     break;
  1873.                 case 'S':
  1874.                     sim2 = TRUE;
  1875.                     break;
  1876.                 case 'G':
  1877.                     grail = TRUE;
  1878.                     break;
  1879.                }
  1880.            }
  1881.        }
  1882.  
  1883.         /* If there is a local backend, install the "dino2" file.  If
  1884.             this is an initial installation, generate the "dino2.init" file. */
  1885.  
  1886.     if (sim1 || sim2 || grail)
  1887.        {
  1888.         (void) fprintf(stderr,
  1889.      "\n\n    Generating a local back end for the DINO compiler . . .\n\n");
  1890.         (void) sprintf(dir, "bin/%s", arch);
  1891.         copy("source/shell2", "dino2", dir, 0);
  1892.         if (! update || newarch)
  1893.            {
  1894.             for (I = 0; I < M; I++)
  1895.                 if (machines[I].type == 's' ||
  1896.                             machines[I].type == 'S' || machines[I].type == 'G')
  1897.                    {
  1898.                     (void) strcpy(name, machines[I].name);
  1899.                     break;
  1900.                    }
  1901.             (void) fprintf(stderr,
  1902. "\n\n         Writing a new configuration file (dino2.init). . .\n");
  1903.             (void) sprintf(name2, "bin/%s/dino2.init", arch);
  1904.             if ((output = fopen(name2, "w")) == NULL)
  1905.                {
  1906.                 (void) fprintf(stderr,
  1907.                   "\n\n\t\tError opening %s\n", name2);
  1908.                 perror("\t\t\t");
  1909.                 (void) fprintf(stderr,
  1910.           "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
  1911.                 exit(1);
  1912.                }
  1913.  
  1914.             if ((input = fopen("source/install/D2I1", "r")) == NULL)
  1915.                {
  1916.                 (void) fprintf(stderr,
  1917.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1918.                                                                         "D2I1");
  1919.                 exit(1);
  1920.                }
  1921.             while (! feof(input))
  1922.                 if (fgets(line, MAXLINESIZE, input) != NULL)
  1923.                     (void) fputs(line, output);
  1924.             (void) fclose(input);
  1925.  
  1926.             (void) fprintf(output, "Dhome=%s\n", current);
  1927.  
  1928.             if ((input = fopen("source/install/D2I2", "r")) == NULL)
  1929.                {
  1930.                 (void) fprintf(stderr,
  1931.       "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1932.                                                                         "D2I2");
  1933.                 exit(1);
  1934.                }
  1935.             while (! feof(input))
  1936.                 if (fgets(line, MAXLINESIZE, input) != NULL)
  1937.                     (void) fputs(line, output);
  1938.             (void) fclose(input);
  1939.  
  1940.             (void) fprintf(output, "Destination=%s\n", name);
  1941.  
  1942.             if ((input = fopen("source/install/D2I3", "r")) == NULL)
  1943.                {
  1944.                 (void) fprintf(stderr,
  1945.       "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1946.                                                                     "D2I3");
  1947.                 exit(1);
  1948.                }
  1949.             while (! feof(input))
  1950.                 if (fgets(line, MAXLINESIZE, input) != NULL)
  1951.                     (void) fputs(line, output);
  1952.             (void) fclose(input);
  1953.  
  1954.             (void) fprintf(output, "Suffix=%s\n", name);
  1955.  
  1956.             (void) fclose(output);
  1957.             (void) fprintf(stderr,
  1958. "         Configuration file (dino2.init) written.\n\n");
  1959.            }
  1960.        }
  1961.  
  1962.         /* For each machine that runs on this machine (local
  1963.             parallel machine), create a machine specific
  1964.             configuration file.  The general type of these
  1965.             files are different for the iPSC1 simulator, the
  1966.                                     iPSC2 simulator, and Grail. */
  1967.  
  1968.    for (I = 0; I < M; I++)
  1969.        {
  1970.         if (machines[I].rsh != 'T' && !update)
  1971.            {
  1972.             switch (machines[I].type)
  1973.                {
  1974.                 case 's':
  1975.                     (void) sprintf(name, "bin/local/new.%s", machines[I].name);
  1976.                     (void) fprintf(stderr,
  1977. "\n\n         Writing a new configuration file (dino2.%s). . .\n",
  1978.                                                         machines[I].name);
  1979.                     if ((output = fopen(name, "w")) == NULL)
  1980.                        {
  1981.                         (void) fprintf(stderr,
  1982.                       "\n\n\t\tError opening %s\n", name);
  1983.                         perror("\t\t\t");
  1984.                         (void) fprintf(stderr,
  1985.           "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
  1986.                         exit(1);
  1987.                        }
  1988.  
  1989.                     if ((input = fopen("source/install/D1S1", "r")) == NULL)
  1990.                        {
  1991.                         (void) fprintf(stderr,
  1992.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  1993.                                                                     "D1S1");
  1994.                         exit(1);
  1995.                        }
  1996.                     while (! feof(input))
  1997.                         if (fgets(line, MAXLINESIZE, input) != NULL)
  1998.                             (void) fputs(line, output);
  1999.                     (void) fclose(input);
  2000.  
  2001.                     (void) fprintf(output, "                   %s \\\n",
  2002.                                                                     sim1loc);
  2003.  
  2004.                     if ((input = fopen("source/install/D1S2", "r")) == NULL)
  2005.                        {
  2006.                         (void) fprintf(stderr,
  2007.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  2008.                                                                         "D1S2");
  2009.                         exit(1);
  2010.                        }
  2011.                     while (! feof(input))
  2012.                         if (fgets(line, MAXLINESIZE, input) != NULL)
  2013.                             (void) fputs(line, output);
  2014.                     (void) fclose(input);
  2015.  
  2016.                     (void) fprintf(output, "                   %s \\\n",
  2017.                                                                     sim1loc);
  2018.  
  2019.                     if ((input = fopen("source/install/DS3", "r")) == NULL)
  2020.                        {
  2021.                         (void) fprintf(stderr,
  2022.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  2023.                                                                         "DS3");
  2024.                         exit(1);
  2025.                        }
  2026.                     while (! feof(input))
  2027.                         if (fgets(line, MAXLINESIZE, input) != NULL)
  2028.                             (void) fputs(line, output);
  2029.                     (void) fclose(input);
  2030.  
  2031.                     (void) fclose(output);
  2032.                     (void) fprintf(stderr,
  2033. "         Configuration file (dino.%s) written.\n\n",
  2034.                                                 machines[I].name);
  2035.                     break;
  2036.                 case 'S':
  2037.                     (void) sprintf(name, "bin/local/new.%s", machines[I].name);
  2038.                     (void) fprintf(stderr,
  2039. "\n\n         Writing a new configuration file (dino2.%s). . .\n",
  2040.                                                         machines[I].name);
  2041.                     if ((output = fopen(name, "w")) == NULL)
  2042.                        {
  2043.                         (void) fprintf(stderr,
  2044.                   "\n\n\t\tError opening %s\n", name);
  2045.                         perror("\t\t\t");
  2046.                         (void) fprintf(stderr,
  2047.           "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
  2048.                         exit(1);
  2049.                        }
  2050.  
  2051.                     if ((input = fopen("source/install/D2S1", "r")) == NULL)
  2052.                        {
  2053.                         (void) fprintf(stderr,
  2054.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  2055.                                                                         "D2S1");
  2056.                         exit(1);
  2057.                        }
  2058.                     while (! feof(input))
  2059.                         if (fgets(line, MAXLINESIZE, input) != NULL)
  2060.                             (void) fputs(line, output);
  2061.                     (void) fclose(input);
  2062.  
  2063.                     (void) fprintf(output, "                   %s \\\n",
  2064.                                                                     sim2loc);
  2065.  
  2066.                     if ((input = fopen("source/install/D2S2", "r")) == NULL)
  2067.                        {
  2068.                         (void) fprintf(stderr,
  2069.       "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  2070.                                                                     "D2S2");
  2071.                         exit(1);
  2072.                        }
  2073.                     while (! feof(input))
  2074.                         if (fgets(line, MAXLINESIZE, input) != NULL)
  2075.                             (void) fputs(line, output);
  2076.                     (void) fclose(input);
  2077.  
  2078.                     (void) fprintf(output, "                   %s \\\n",
  2079.                                                                     sim2loc);
  2080.  
  2081.                     if ((input = fopen("source/install/DS3", "r")) == NULL)
  2082.                        {
  2083.                         (void) fprintf(stderr,
  2084.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  2085.                                                                         "DS3");
  2086.                         exit(1);
  2087.                        }
  2088.                     while (! feof(input))
  2089.                         if (fgets(line, MAXLINESIZE, input) != NULL)
  2090.                             (void) fputs(line, output);
  2091.                     (void) fclose(input);
  2092.  
  2093.                     (void) fclose(output);
  2094.                     (void) fprintf(stderr,
  2095. "         Configuration file (dino.%s) written.\n\n",
  2096.                                                 machines[I].name);
  2097.                     break;
  2098.                 case 'G':
  2099.                     break;
  2100.                }
  2101.            }
  2102.        }
  2103.  
  2104.         /* If there is an iPSC1 simulator installed here, install the
  2105.             appropriate example, and create the necessary backend library. */
  2106.  
  2107.     if (sim1)
  2108.        {
  2109.         (void) fprintf(stderr,
  2110.         "\n\n    Setting up the local files for an iPSC1 simulator . . .\n\n");
  2111.         copy("source/shell2", "dino2.simulator1.example", "bin/local", 0);
  2112.         (void) sprintf(name, "ARCHTYPE=%s", arch);
  2113.         (void) fprintf(stderr,
  2114.         "\n\n    Generating the DINO library for an iPSC1 simulator . . .\n\n");
  2115.         if (fork())
  2116.            {
  2117.             (void) wait(&status);
  2118.             if (status)
  2119.                {
  2120.                 (void) fprintf(stderr,
  2121.                  "\n\n    Make failed for the back end for %s.\n", line);
  2122.                 (void) fprintf(stderr,
  2123.                   "        Contact dino@cs.colorado.edu for help.\n\n");
  2124.                 return(0);
  2125.                }
  2126.            }
  2127.         else
  2128.            {
  2129.             (void) chdir("source/library");
  2130.             (void) execlp("make", "make", name, "sim1", 0);
  2131.            }
  2132.        }
  2133.  
  2134.         /* If there is an iPSC2 simulator installed here, install the
  2135.             appropriate example, and create the necessary backend library. */
  2136.  
  2137.  
  2138.     if (sim2)
  2139.        {
  2140.         (void) fprintf(stderr,
  2141.         "\n\n    Setting up the local files for an iPSC2 simulator . . .\n\n");
  2142.         copy("source/shell2", "dino2.simulator2.example", "bin/local", 0);
  2143.          (void) sprintf(name, "ARCHTYPE=%s", arch);
  2144.         (void) fprintf(stderr,
  2145.         "\n\n    Generating the DINO library for an iPSC2 simulator . . .\n\n");
  2146.         if (fork())
  2147.            {
  2148.             (void) wait(&status);
  2149.             if (status)
  2150.                {
  2151.                 (void) fprintf(stderr,
  2152.                  "\n\n    Make failed for the back end for %s.\n", line);
  2153.                 (void) fprintf(stderr,
  2154.                   "        Contact dino@cs.colorado.edu for help.\n\n");
  2155.                 return(0);
  2156.                }
  2157.            }
  2158.         else
  2159.            {
  2160.             (void) chdir("source/library");
  2161.             (void) execlp("make", "make", name, "sim2", 0);
  2162.            }
  2163.        }
  2164.  
  2165.         /* If Grail is installed here, install the
  2166.             appropriate example, and create the necessary backend library. */
  2167.  
  2168.     if (grail)
  2169.        {
  2170.        }
  2171.  
  2172.         /* If there are any back end machines on this machine (local
  2173.             parallel machine), make the backend shell (that means,
  2174.             compile the various programs "dino2" uses, rename the
  2175.             "new" files as appropriate, and create any necessary links). */
  2176.  
  2177.     if (sim1 || sim2 || grail)
  2178.        {
  2179.         (void) fprintf(stderr,
  2180.                  "\n    Doing the last part of the DINO backend . . .\n\n");
  2181.          (void) sprintf(name, "ARCHTYPE=%s", arch);
  2182.         if (! update)
  2183.            {
  2184.             for (I = 0; machines[I].type != 's' &&
  2185.                             machines[I].type != 'S' && machines[I].type != 'G'; I++);
  2186.             (void) sprintf(name2, "DEST=%s", machines[I].name);
  2187.             for (I++; I < M; I++)
  2188.                 if (machines[I].type == 's' ||
  2189.                             machines[I].type == 'S' || machines[I].type == 'G')
  2190.                    {
  2191.                     (void) strcat(name2, " ");
  2192.                     (void) strcat(name2, machines[I].name);
  2193.                    }
  2194.            }
  2195.         if (fork())
  2196.            {
  2197.             (void) wait(&status);
  2198.             if (status)
  2199.                {
  2200.                 (void) fprintf(stderr,
  2201.                  "\n\n    Make failed for the back end for %s.\n", name);
  2202.                 (void) fprintf(stderr,
  2203.                   "        Contact dino@cs.colorado.edu for help.\n\n");
  2204.                 return(0);
  2205.                }
  2206.            }
  2207.         else
  2208.            {
  2209.             (void) chdir("source/shell2");
  2210.             if (update)
  2211.                {
  2212.                 if (newarch)
  2213.                     (void) execlp("make", "make", name, "INIT=YES", "all", 0);
  2214.                 else
  2215.                     (void) execlp("make", "make", name, "all", 0);
  2216.                }
  2217.             else
  2218.                 (void) execlp("make", "make", name, "INIT=YES", name2, "all", 0); 
  2219.            }
  2220.         (void) fprintf(stderr,
  2221.                  "\n    DINO backend for local machines finished.\n\n");
  2222.        }
  2223.  
  2224.         /* Now, for each remote parallel machine that we
  2225.                         want installed, put in the whole backend. */
  2226.  
  2227.     if (backend)
  2228.         for (I = 0; I < M; I++)
  2229.            {
  2230.             machines[I].install = FALSE;
  2231.             if (machines[I].rsh == 'T' && machines[I].rmt_install != 'N')
  2232.                {
  2233.                 machines[I].install = TRUE;
  2234.                 for (J = 0; J < I; J++)
  2235.                     if (strcmp(machines[I].address, machines[J].address) == 0)
  2236.                        {
  2237.                         machines[I].install = FALSE;
  2238.                         break;
  2239.                        }
  2240.                }
  2241.            }
  2242.  
  2243.     for (I = 0; I < M; I++)
  2244.        {
  2245.         if (machines[I].install && backend)
  2246.            {
  2247.             (void) fprintf(stderr,
  2248.             "\n    Generating the back end for %s . . .\n\n", machines[I].name);
  2249.             switch (machines[I].type)
  2250.                {
  2251.                 case '1':
  2252.                     (void) strcpy(target, "iPSC1");
  2253.                     break;
  2254.                 case '2':
  2255.                     (void) strcpy(target, "iPSC2");
  2256.                     break;
  2257.                 case '8':
  2258.                     (void) strcpy(target, "i860");
  2259.                     break;
  2260.                }
  2261.             (void) fprintf(stderr,
  2262.                             "        Creating a local copy of the directories\n");
  2263.             (void) fprintf(stderr,
  2264.                             "             and files needed for %s . . .\n",
  2265.                                                                 machines[I].name);
  2266.             if (machines[I].rmt_install == 'R' || machines[I].rmt_install == 'M')
  2267.                {
  2268.                 maked(machines[I].name, (char *) NULL, current);
  2269.                 (void) sprintf(targetd, "%s/%s", current, machines[I].name);
  2270.                }
  2271.             else
  2272.                 (void) strcpy(targetd, machines[I].lcl_directory);
  2273.             if (machines[I].rmt_install == 'M')
  2274.                {
  2275.                  (void) fprintf(stderr,
  2276.                             "\n        Writing a manual Makefile . . .\n");
  2277.                 (void) sprintf(name, "%s/Makefile", targetd);
  2278.                    if ((output = fopen(name, "w")) == NULL)
  2279.                    {
  2280.                     (void) fprintf(stderr,
  2281.                               "\n\n\t\tError opening %s\n", name);
  2282.                     perror("\t\t\t");
  2283.                     (void) fprintf(stderr,
  2284.           "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
  2285.                     exit(1);
  2286.                    }
  2287.                 if (update)
  2288.                         (void) strcpy(name2, "all");
  2289.                 else
  2290.                         (void) sprintf(name2, "INIT=YES DEST=%s all", machines[I].name);
  2291.                    (void) fprintf(output, "all\t:\n");
  2292.                 (void) fprintf(output, "\t@cd source/library; make %s\n", target);
  2293.                 (void) fprintf(output, "\t@cd source/shell2; make ARCHTYPE=%s %s\n", target, name2);
  2294.                 (void) fclose(output);
  2295.                  (void) fprintf(stderr,
  2296.                             "        Manual Makefile done.\n");
  2297.                }
  2298.  
  2299.             maked("bin", (char *) NULL, targetd);
  2300.  
  2301.             maked("local", "bin", targetd);
  2302.             (void) sprintf(name, "dino2.%s.example", target);
  2303.             (void) sprintf(sourced, "%s/source/shell2", current);
  2304.             (void) sprintf(dir, "%s/bin/local", targetd);
  2305.             copy(sourced, name, "dino2.init.example", dir, 0);
  2306.             if (! update)
  2307.                {
  2308.                 (void) sprintf(name2, "%s/new.%s", dir, machines[I].name);
  2309.                 copy(sourced, name, name2, 0);
  2310.                }
  2311.  
  2312.             maked(target, "bin", targetd);
  2313.             (void) sprintf(dir, "%s/bin/%s", targetd, target);
  2314.             copy(sourced, "dino2", dir, 0);
  2315.             if (! update)
  2316.                {
  2317.                 (void) fprintf(stderr,
  2318.             "\n           Writing a new configuration file (dino2.init). . .\n");
  2319.                 (void)sprintf(name, "%s/bin/%s/new.init", targetd, target);
  2320.                 if ((output = fopen(name, "w")) == NULL)
  2321.                    {
  2322.                     (void) fprintf(stderr,
  2323.                                   "\n\n\t\tError opening %s\n", name);
  2324.                     perror("\t\t\t");
  2325.                     (void) fprintf(stderr,
  2326.           "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
  2327.                     exit(1);
  2328.                    }
  2329.  
  2330.                 if ((input = fopen("source/install/D2I1", "r")) == NULL)
  2331.                    {
  2332.                     (void) fprintf(stderr,
  2333.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  2334.                                                                 "D2I1");
  2335.                     exit(1);
  2336.                    }
  2337.                 while (! feof(input))
  2338.                     if (fgets(line, MAXLINESIZE, input) != NULL)
  2339.                         (void) fputs(line, output);
  2340.                 (void) fclose(input);
  2341.  
  2342.                 (void) fprintf(output, "Dhome=%s\n", machines[I].rmt_directory);
  2343.  
  2344.                 if ((input = fopen("source/install/D2I2", "r")) == NULL)
  2345.                    {
  2346.                     (void) fprintf(stderr,
  2347.       "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  2348.                                                                         "D2I2");
  2349.                     exit(1);
  2350.                    }
  2351.                 while (! feof(input))
  2352.                     if (fgets(line, MAXLINESIZE, input) != NULL)
  2353.                         (void) fputs(line, output);
  2354.                 (void) fclose(input);
  2355.  
  2356.                 (void) fprintf(output, "Destination=%s\n", machines[I].name);
  2357.  
  2358.                 if ((input = fopen("source/install/D2I3", "r")) == NULL)
  2359.                    {
  2360.                     (void) fprintf(stderr,
  2361.      "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
  2362.                                                                         "D2I3");
  2363.                     exit(1);
  2364.                    }
  2365.                 while (! feof(input))
  2366.                     if (fgets(line, MAXLINESIZE, input) != NULL)
  2367.                         (void) fputs(line, output);
  2368.                 (void) fclose(input);
  2369.  
  2370.                 (void) fprintf(output, "Suffix=%s\n", machines[I].name);
  2371.  
  2372.                 (void) fclose(output);
  2373.  
  2374.                 (void) fprintf(stderr,
  2375.             "           Configuration file (dino2.init) written.\n");
  2376.                }
  2377.  
  2378.             maked("lib", (char *) NULL, targetd);
  2379.  
  2380.             maked(target, "lib", targetd);
  2381.  
  2382.             maked("source", (char *) NULL, targetd);
  2383.  
  2384.             maked("shell2", "source", targetd);
  2385.             (void) sprintf(dir, "%s/source/shell2", targetd);
  2386.             copy(sourced, "Makefile", "Makescript", "dinocrdr", "newer2.c",
  2387.                             "rootextr.c", "returndir.c", dir, 0);
  2388.  
  2389.             maked("inc", "source", targetd);
  2390.             (void) sprintf(dir, "%s/source/inc", targetd);
  2391.             (void) sprintf(sourced, "%s/source/inc", current);
  2392.             copy(sourced, "*", dir, 0);
  2393.  
  2394.             maked("library", "source", targetd);
  2395.             (void) sprintf(dir, "%s/source/library", targetd);
  2396.             (void) sprintf(sourced, "%s/source/library", current);
  2397.             copy(sourced, "D_bitmaps.c", "D_lib.c", "D_reduct.c",
  2398.                     "hostinit.c", "internal.c", "node_main.c",
  2399.                     "quick.c", "route.c", "stub.c", "timer.c", dir, 0);
  2400.             if (machines[I].type == '1')
  2401.                {
  2402.                 copy(sourced, "copy.obj", dir, 0);
  2403.                 (void) strcat(dir, "/Makefile");
  2404.                 copy(sourced, "Makefile.iPSC1", dir, 0);
  2405.                }
  2406.             else
  2407.                 copy(sourced, "copy2.s", "Makefile", dir, 0);
  2408.  
  2409.             switch (machines[I].rmt_install)
  2410.                {
  2411.                 case 'R':
  2412.                     (void) fprintf(stderr,
  2413.                     " \n       Copying the directories and files to %s . . .\n",
  2414.                                                                 machines[I].name);
  2415.                     if (machines[I].rmt_user[0] != '\0')
  2416.                         (void) sprintf(name, "%s@%s:%s",
  2417.                                                     machines[I].rmt_user,
  2418.                                                     machines[I].address,
  2419.                                                     machines[I].rmt_directory);
  2420.                     else
  2421.                         (void) sprintf(name, "%s:%s", machines[I].address,
  2422.                                                     machines[I].rmt_directory);
  2423.  
  2424.                     if (fork())
  2425.                        {
  2426.                         (void) wait(&status);
  2427.                         if (status)
  2428.                            {
  2429.                             (void) fprintf(stderr,
  2430.                      "\n\n    \"rcp\" failed for the back end for %s.\n",
  2431.                                                             machines[I].name);
  2432.                             (void) fprintf(stderr,
  2433.                        "        Contact dino@cs.colorado.edu for help.\n\n");
  2434.                             return(0);
  2435.                            }
  2436.                        }
  2437.                     else
  2438.                        {
  2439.                         if (machines[I].type == '1')
  2440.                             (void) strcpy(name2, "-r");
  2441.                         else
  2442.                             (void) strcpy(name2, "-pr");
  2443.                         (void) chdir(machines[I].name);
  2444.                         (void) execlp("rcp", "rcp", name2, "bin",
  2445.                                                     "lib", "source", name, 0);
  2446.                        }
  2447.  
  2448.                     (void) fprintf(stderr,
  2449.         "\n       Deleting the local copy of the directories and files . . .\n");
  2450.                     if (fork())
  2451.                        {
  2452.                         (void) wait(&status);
  2453.                         if (status)
  2454.                            {
  2455.                             (void) fprintf(stderr,
  2456.                      "\n\n    \"rm -rf\" failed for the back end for %s.\n",
  2457.                                                             machines[I].name);
  2458.                             (void) fprintf(stderr,
  2459.                        "        Contact dino@cs.colorado.edu for help.\n\n");
  2460.                             return(0);
  2461.                            }
  2462.                        }
  2463.                     else
  2464.                        {
  2465.                         (void) execlp("rm", "rm", "-rf", machines[I].name, 0);
  2466.                        }
  2467.  
  2468.                     (void) fprintf(stderr,
  2469.                     "\n   Making the back end on %s:\n\n", machines[I].name);
  2470.                     (void) fprintf(stderr, "       libraries first . . .\n\n");
  2471.  
  2472.                     (void) sprintf(name, "%s/source/library",
  2473.                                                 machines[I].rmt_directory);
  2474.                     if (fork())
  2475.                        {
  2476.                         (void) wait(&status);
  2477.                         if (status)
  2478.                            {
  2479.                             (void) fprintf(stderr,
  2480.                      "\n\n    \"rsh make library\" failed for the back end for %s.\n",
  2481.                                                             machines[I].name);
  2482.                             (void) fprintf(stderr,
  2483.                        "        Contact dino@cs.colorado.edu for help.\n\n");
  2484.                             return(0);
  2485.                            }
  2486.                        }
  2487.                     else
  2488.                        {
  2489.                         if (machines[I].rmt_user[0] != '\0')
  2490.                             (void) execlp("rsh", "rsh", "-l",
  2491.                                             machines[I].rmt_user,
  2492.                                             machines[I].address,
  2493.                                             "cd", name, ";", "make", target, 0);
  2494.                         else
  2495.                                (void) execlp("rsh", "rsh", machines[I].address, "cd",
  2496.                                                     name, ";", "make", target, 0);
  2497.                        }
  2498.  
  2499.                     (void) fprintf(stderr,
  2500.                         "\n       then the back-end shell . . .\n\n");
  2501.  
  2502.                     (void) sprintf(dir, "%s/source/shell2", machines[I].rmt_directory);
  2503.                     (void) sprintf(name, "ARCHTYPE=%s", target);
  2504.                     (void) sprintf(name2, "DEST=%s", machines[I].name);
  2505.                     if (fork())
  2506.                        {
  2507.                         (void) wait(&status);
  2508.                         if (status)
  2509.                            {
  2510.                             (void) fprintf(stderr,
  2511.                      "\n\n    \"rsh make shell2\" failed for the back end for %s.\n",
  2512.                                                             machines[I].name);
  2513.                             (void) fprintf(stderr,
  2514.                        "        Contact dino@cs.colorado.edu for help.\n\n");
  2515.                             return(0);
  2516.                            }
  2517.                        }
  2518.                     else
  2519.                        {
  2520.                         if (machines[I].rmt_user[0] != '\0')
  2521.                            {
  2522.                             if (update)
  2523.                                 (void) execlp("rsh", "rsh", "-l",
  2524.                                             machines[I].rmt_user,
  2525.                                             machines[I].address,
  2526.                                             "cd", dir, ";", "make", name, "INIT=YES", name2, "all", 0);
  2527.                             else
  2528.                                 (void) execlp("rsh", "rsh", "-l",
  2529.                                             machines[I].rmt_user,
  2530.                                             machines[I].address,
  2531.                                             "cd", dir, ";", "make", name, "all", 0);
  2532.                            }
  2533.                         else
  2534.                            {
  2535.                             if (update)
  2536.                                 (void) execlp("rsh", "rsh",
  2537.                                             machines[I].address, "cd",
  2538.                                                 dir, ";", "make", name, "all", 0);
  2539.                             else
  2540.                                 (void) execlp("rsh", "rsh",
  2541.                                             machines[I].address, "cd",
  2542.                                                 dir, ";", "make", name, "INIT=YES", name2, "all", 0);
  2543. /*                                (void) fprintf(stderr, "%s %s %s %s %s %s %s %s %s %s %s\n\n", "rsh", "rsh",
  2544.                                             machines[I].address, "cd",
  2545.                                                 dir, ";", "make", name, "INIT=YES", name2, "all", 0); */
  2546.                            }
  2547.                        }
  2548.                     break;
  2549.                 case 'L':
  2550.                     (void) fprintf(stderr,
  2551.                     " \n   Making the back end on %s:\n\n",
  2552.                                                                 machines[I].name);
  2553.                     (void) fprintf(stderr,
  2554.                                 "       the back-end shell first . . .\n\n");
  2555.  
  2556.                     (void) sprintf(dir,
  2557.                                 "%s/source/shell2", machines[I].rmt_directory);
  2558.                     (void) sprintf(name, "ARCHTYPE=%s", target);
  2559.                     (void) sprintf(name2, "DEST=%s", machines[I].name);
  2560.                     if (fork())
  2561.                        {
  2562.                         (void) wait(&status);
  2563.                         if (status)
  2564.                            {
  2565.                             (void) fprintf(stderr,
  2566.                      "\n\n    \"rsh make shell2\" failed for the back end for %s.\n",
  2567.                                                             machines[I].name);
  2568.                             (void) fprintf(stderr,
  2569.                        "        Contact dino@cs.colorado.edu for help.\n\n");
  2570.                             return(0);
  2571.                            }
  2572.                        }
  2573.                     else
  2574.                        {
  2575.                         if (machines[I].rmt_user[0] != '\0')
  2576.                            {
  2577.                             if (update)
  2578.                                 (void) execlp("rsh", "rsh", "-l",
  2579.                                             machines[I].rmt_user,
  2580.                                             machines[I].address,
  2581.                                             "cd", dir, ";", "make", name, "all", 0);
  2582.                             else
  2583.                                 (void) execlp("rsh", "rsh", "-l",
  2584.                                             machines[I].rmt_user,
  2585.                                             machines[I].address,
  2586.                                             "cd", dir, ";", "make",
  2587.                                             name, "INIT=YES", name2, "all", 0);
  2588.                            }
  2589.                         else
  2590.                            {
  2591.                             if (update)
  2592.                                 (void) execlp("rsh", "rsh",
  2593.                                             machines[I].address, "cd",
  2594.                                                 dir, ";", "make", name, "all", 0);
  2595.                             else
  2596.                                 (void) execlp("rsh", "rsh",
  2597.                                             machines[I].address, "cd",
  2598.                                             dir, ";", "make", name,
  2599.                                             "INIT=YES", name2, "all", 0);
  2600.                            }
  2601.                        }
  2602.  
  2603.                     (void) fprintf(stderr,
  2604.                                 "\n       then the libraries . . .\n\n");
  2605.  
  2606.                     (void) sprintf(name, "%s/source/library", machines[I].rmt_directory);
  2607.                     if (fork())
  2608.                        {
  2609.                         (void) wait(&status);
  2610.                         if (status)
  2611.                            {
  2612.                             (void) fprintf(stderr,
  2613.                      "\n\n    \"rsh make library\" failed for the back end for %s.\n",
  2614.                                                             machines[I].name);
  2615.                             (void) fprintf(stderr,
  2616.                        "        Contact dino@cs.colorado.edu for help.\n\n");
  2617.                             return(0);
  2618.                            }
  2619.                        }
  2620.                     else
  2621.                        {
  2622.                         if (machines[I].rmt_user[0] != '\0')
  2623.                             (void) execlp("rsh", "rsh", "-l",
  2624.                                                 machines[I].rmt_user,
  2625.                                                 machines[I].address, "cd",
  2626.                                                 name, ";", "make", target, 0);
  2627.                         else
  2628.                             (void) execlp("rsh", "rsh", machines[I].address,
  2629.                                                 "cd", name, ";", "make", target, 0);
  2630.                        }
  2631.                     break;
  2632.                }
  2633.             (void) fprintf(stderr,
  2634.             "\n    Back end for %s is finished.\n\n", machines[I].name);
  2635.  
  2636.            }
  2637.        }
  2638.  
  2639.     (void) fprintf(stderr, "    (Hit return to continue)");
  2640.     get_line(enter);
  2641.  
  2642.     if (update)
  2643.        {
  2644.         if (backend)
  2645.            {
  2646.             (void) fprintf(stderr, "\n\n\n\n\n\n\n\n%s", messages[56]);
  2647.             for (I = 0; I < M; I++)
  2648.                 (void) fprintf(stderr, "        %s\n", machines[I].name);
  2649.             bingo = FALSE;
  2650.             for (I = 0; I < M; I++)
  2651.                 if (machines[I].rmt_install == 'M')
  2652.                    {
  2653.                     bingo = TRUE;
  2654.                     (void) fprintf(stderr, "\n    (Hit return to continue)");
  2655.                     get_line(enter);
  2656.                     (void) fprintf(stderr, "%s%s%s%s/%s\n\n%s%s\n\n%s%s%s%s\n\n%s",
  2657.                                     messages[57], machines[I].name, messages[58],
  2658.                                     current, machines[I].name, messages[41],
  2659.                                     machines[I].rmt_directory, messages[42],
  2660.                                     machines[I].name, messages[43],
  2661.                                     machines[I].rmt_directory, messages[44]);
  2662.                    }
  2663.                 if (bingo)
  2664.                    {
  2665.                     (void) fprintf(stderr, "\n    (Hit return to continue)");
  2666.                     get_line(enter);
  2667.                    }
  2668.            }
  2669.         else
  2670.             (void) fprintf(stderr, "\n\n\n\n\n\n\n\n%s", messages[62]);
  2671.         (void) fprintf(stderr, "%s", messages[59]);
  2672.        }
  2673.     else
  2674.        {
  2675.         (void) fprintf(stderr, "\n\n\n\n\n\n\n\n%s%s%s%s%s",
  2676.                      messages[34], current, messages[35], current, messages[36]);
  2677.         get_line(enter);
  2678.         (void) fprintf(stderr,
  2679.                         "\n\n    DINO has defined %d parallel machine%s:\n\n",
  2680.                                                                   M, M>1?"s":"");
  2681.         for (I = 0; I < M; I++)
  2682.            {
  2683.             (void) fprintf(stderr, "    %s:\n", machines[I].name);
  2684.             if (machines[I].rsh == 'T')
  2685.                {
  2686.                 switch (machines[I].type)
  2687.                    {
  2688.                     case '1':
  2689.                         (void) strcpy(target, "iPSC1");
  2690.                         break;
  2691.                     case '2':
  2692.                         (void) strcpy(target, "iPSC2");
  2693.                         break;
  2694.                     case '8':
  2695.                         (void) strcpy(target, "i860");
  2696.                         break;
  2697.                    }
  2698.                 (void) fprintf(stderr, "%s%s%s%s%s", messages[37], target,
  2699.                          messages[38], machines[I].rmt_directory, messages[39]);
  2700.                 if (machines[I].rmt_install == 'M')
  2701.                    {
  2702.                     (void) fprintf(stderr, "%s%s/%s\n\n%s%s\n\n%s%s%s%s\n\n%s",
  2703.                                 messages[40], current, machines[I].name,
  2704.                                 messages[41], machines[I].rmt_directory,
  2705.                                 messages[42], machines[I].name, messages[43],
  2706.                                 machines[I].rmt_directory, messages[44]);
  2707.                    }
  2708.                 (void) fprintf(stderr, "%s", messages[45]);
  2709.                 get_line(enter);
  2710.                 (void) fprintf(stderr, "\n\n");
  2711.                }
  2712.             else
  2713.                {
  2714.                 if (machines[I].run == 'F')
  2715.                    {
  2716.                     (void) fprintf(stderr, "%s", messages[46]);
  2717.                     get_line(enter);
  2718.                     (void) fprintf(stderr, "\n\n");
  2719.                    }
  2720.                 else
  2721.                    {
  2722.                     (void) fprintf(stderr, "%s", messages[47]);
  2723.                     get_line(enter);
  2724.                     (void) fprintf(stderr, "\n\n");
  2725.                    }
  2726.                }
  2727.            }
  2728.         bingo = FALSE;
  2729.         for (I = 0; I < M; I++)
  2730.             if (machines[I].rsh == 'T')
  2731.                {
  2732.                 bingo = TRUE;
  2733.                 break;
  2734.                }
  2735.  
  2736.         if (bingo)
  2737.            {
  2738.             (void) fprintf(stderr, "%s", messages[48]);
  2739.             get_line(enter);
  2740.             (void) fprintf(stderr, "\n\n");
  2741.            }
  2742.  
  2743.         if (strcmp(arch, "sun4") == 0)
  2744.             (void) strcpy(target, "sun3");
  2745.         else
  2746.             (void) strcpy(target, "sun4");
  2747.  
  2748.         (void) fprintf(stderr, "%s%s%s%s%s", messages[49], arch,
  2749.                                             messages[50], target, messages[51]);
  2750.         get_line(enter);
  2751.         (void) fprintf(stderr, "\n\n");
  2752.         (void) fprintf(stderr, "%s", messages[52]);
  2753.        }
  2754.  
  2755.     return(0);
  2756.    }
  2757.  
  2758.  
  2759. /*********************************************************************
  2760.  *
  2761.  *  This function is used to get a yes/no answer.  It returns:
  2762.  *
  2763.  *    -1 if the user wants to quit the automated installer
  2764.  *     0 if the user wants to start this machine over
  2765.  *     1 if the answer is yes
  2766.  *     2 if the answer is no
  2767.  *
  2768.  *  The parameter is the current machine number.
  2769.  *
  2770.  ********************************************************************/
  2771.  
  2772. static int get_yn(number)
  2773.     int number;
  2774.    {
  2775.     char enter[MAXLINESIZE];
  2776.  
  2777.     for(;;)
  2778.        {
  2779.         (void) fprintf(stderr, "             (Y/N) ==> ");
  2780.         get_line(enter);
  2781.         if (enter[0] == '\0')
  2782.            {
  2783.             (void) fprintf(stderr, "%s%d%s", messages[12], number, messages[13]);
  2784.             get_line(enter);
  2785.             if (enter[0] =='Q' || enter[0] == 'q')
  2786.                 return(-1);
  2787.             if (enter[0] =='\0')
  2788.                 return(0);
  2789.            }
  2790.         if (enter[0] != 'Y' && enter[0] != 'y' &&
  2791.                                             enter[0] != 'N' && enter[0] != 'n')
  2792.            {
  2793.             (void) fprintf(stderr, "%s", messages[14]);
  2794.             continue;
  2795.            }
  2796.         else
  2797.            {
  2798.             if (enter[0] == 'Y' || enter[0] == 'y')
  2799.                 return(1);
  2800.             else
  2801.                 return(2);
  2802.            }
  2803.        }
  2804.    }
  2805.  
  2806. /********************************************************************
  2807.  *
  2808.  *  Gets a line from stdio.  Takes a pointer to an existing string,
  2809.  *    turns the line into a string.
  2810.  *
  2811.  ********************************************************************/
  2812.  
  2813. static void get_line(str)
  2814.     char *str;
  2815.    {
  2816.     int I = 0;
  2817.  
  2818.     do
  2819.         str[I++] = getchar();
  2820.     while ((str[I - 1] != '\n') && (I < MAXLINESIZE - 1));
  2821.     str[I - 1] = '\0';
  2822.    }
  2823.  
  2824.  
  2825. /********************************************************************
  2826.  *
  2827.  *  Gets a line from stdio.  If the line is empty, asks if the
  2828.  *    user wants to quit or start this machine over.  Takes a
  2829.  *    pointer to an existing string, turns the line into a
  2830.  *    string.  Also takes the number of the machine being
  2831.  *    defined.
  2832.  *
  2833.  ********************************************************************/
  2834.  
  2835. static int get_line_quit(str, number)
  2836.     char *str;
  2837.     int number;
  2838.    {
  2839.     get_line(str);
  2840.     if (str[0] =='\0')
  2841.        {
  2842.         (void) fprintf(stderr,
  2843. "\n    If you want to quit the Automated Installer, enter a \"Q\" now;\n");
  2844.         (void) fprintf(stderr,
  2845. "    otherwise just hit return to start machine #%d over ==>", number);
  2846.          get_line(str);
  2847.          if (str[0] =='Q' || str[0] == 'q')
  2848.              exit(0);
  2849.          else
  2850.              return(1);
  2851.         }
  2852.     return(0);
  2853.    }
  2854.  
  2855.  
  2856. /********************************************************************
  2857.  *
  2858.  * Copies one or more files.  The parameters are the source
  2859.  *    directory, one or more files, (optionally) a target
  2860.  *    directory, and a NULL pointer.  The source directory
  2861.  *    can be NULL, in which case, it is assumed to be the
  2862.  *    current directory.  If the last (non NULL) parameter
  2863.  *    is not a directory, there can only be two files, the
  2864.  *    first being copied to the second (i.e., allows you to
  2865.  *    rename the file being copied).  If the second parameter
  2866.  *    is a "*", all files in the source directory are copied
  2867.  *    and there must be a target directory.  Permissions are
  2868.  *    maintained.  Exits with an error message if it fails.
  2869.  *
  2870.  ********************************************************************/
  2871.  
  2872. static void copy(va_alist)
  2873.     va_dcl
  2874.    {
  2875.     va_list parm;
  2876.     int count;
  2877.     int I;
  2878.     int size;
  2879.     BOOL all = FALSE;
  2880.     BOOL single = FALSE;
  2881.     BOOL docopy;
  2882.     char *source, *target, *file;
  2883.     char input[MAXPATHLEN], output[MAXPATHLEN];
  2884.     char buffer[BUFSIZE];
  2885.     int fdin, fdout;
  2886.     DIR *dirp;
  2887.     struct dirent *entry;
  2888.     struct stat buf1, buf2;
  2889.     struct utimbuf ftime;
  2890.     char *name;
  2891.  
  2892.     va_start(parm);
  2893.     source = va_arg(parm, char *);
  2894.     file = va_arg(parm, char *);
  2895.     if (file[0] == '*')
  2896.        {
  2897.         all = TRUE;
  2898.         target =  va_arg(parm, char *);
  2899.         if (stat(target, &buf1) != 0 || ! S_ISDIR(buf1.st_mode))
  2900.             copyerr();
  2901.        }
  2902.     else
  2903.        {
  2904.         for(count = 0; file != NULL;
  2905.                         count++, target = file, file = va_arg(parm, char *));
  2906.         count--;
  2907.         if ((single = (stat(target, &buf1) != 0 || S_ISREG(buf1.st_mode))) &&
  2908.                                                                 count != 1)
  2909.             copyerr();
  2910.        }
  2911.     va_end(parm);
  2912.     
  2913.  
  2914.     if (all)
  2915.        {
  2916.         if ((dirp = opendir(source)) == NULL)
  2917.             copyerr(1, source);
  2918.         while((entry = readdir(dirp)) != NULL)
  2919.            {
  2920.             if (source != NULL)
  2921.                 (void) sprintf(input, "%s/%s", source, entry->d_name);
  2922.             else
  2923.                 (void) strcpy(input, entry->d_name);
  2924.             if (stat(input, &buf1) == 0)
  2925.                {
  2926.                 if (S_ISREG(buf1.st_mode))
  2927.                    {
  2928.                     (void) sprintf(output, "%s/%s", target, entry->d_name);
  2929.                     docopy = FALSE;
  2930.                     if (stat(output, &buf2) == 0)
  2931.                        {
  2932.                         if (buf1.st_mtime > buf2.st_mtime)
  2933.                             docopy = TRUE;
  2934.                        }
  2935.                     else
  2936.                         if (errno == ENOENT)
  2937.                             docopy = TRUE;
  2938.                         else
  2939.                             copyerr(3, entry->d_name);
  2940.                     if (docopy)
  2941.                        {
  2942.                         if ((fdin = open(input, O_RDONLY)) < 0)
  2943.                             copyerr(2, entry->d_name);
  2944.                         if ((fdout = open(output,
  2945.                             O_CREAT | O_WRONLY | O_TRUNC, buf1.st_mode)) < 0)
  2946.                             copyerr(3, entry->d_name);
  2947.                         while ((size = read(fdin, buffer, BUFSIZE)) > 0)
  2948.                             if (write(fdout, buffer, size) != size)
  2949.                                 copyerr(4, entry->d_name);
  2950.                         if (size < 0)
  2951.                             copyerr(5, entry->d_name);
  2952.                         (void) fprintf(stderr,
  2953.                             "            Copying %s . . .\n", entry->d_name);
  2954.                         (void) close(fdin);
  2955.                         (void) close(fdout);
  2956.                         ftime.actime = buf1.st_atime;
  2957.                         ftime.modtime = buf1.st_mtime;
  2958.                         (void) utime(output, &ftime);
  2959.                        }
  2960.                     else
  2961.                         (void) fprintf(stderr,
  2962.                             "            %s is up to date.\n", entry->d_name);
  2963.                    }
  2964.                }
  2965.             else
  2966.                 copyerr(6, entry->d_name);
  2967.            }
  2968.         (void) closedir(dirp);
  2969.        }
  2970.     else
  2971.        {
  2972.         va_start(parm);
  2973.         file = va_arg(parm, char *);
  2974.         for (I = 0; I < count; I++)
  2975.            {
  2976.             file = va_arg(parm, char *);
  2977.             if (source != NULL)
  2978.                 (void) sprintf(input, "%s/%s", source, file);
  2979.             else
  2980.                 (void) strcpy(input, file);
  2981.             if (single)
  2982.                 (void) strcpy(output, target);
  2983.             else
  2984.                 (void) sprintf(output, "%s/%s", target, file);
  2985.             if (stat(input, &buf1) != 0)
  2986.                 copyerr(6, file);
  2987.             docopy = FALSE;
  2988.             if (stat(output, &buf2) == 0)
  2989.                {
  2990.                 if (buf1.st_mtime > buf2.st_mtime)
  2991.                     docopy = TRUE;
  2992.                }
  2993.             else
  2994.                 if (errno == ENOENT)
  2995.                     docopy = TRUE;
  2996.                 else
  2997.                     copyerr(3, single?target:file);
  2998.             if (docopy)
  2999.                {
  3000.                 if ((fdin = open(input, O_RDONLY)) < 0)
  3001.                     copyerr(2, file);
  3002.                 if ((fdout = open(output,
  3003.                             O_CREAT | O_WRONLY | O_TRUNC, buf1.st_mode)) < 0)
  3004.                     copyerr(3, single?target:file);
  3005.                 while ((size = read(fdin, buffer, BUFSIZE)) > 0)
  3006.                     if (write(fdout, buffer, size) != size)
  3007.                         copyerr(4, file);
  3008.                 if (size < 0)
  3009.                     copyerr(5, single?target:file);
  3010.                 if (single)
  3011.                    {
  3012.                     if ((name = strrchr(target, '/')) == NULL)
  3013.                         name = target;
  3014.                     else
  3015.                         name++;
  3016.                    }
  3017.                 else
  3018.                     name = file;
  3019.                 (void) fprintf(stderr,
  3020.                                     "            Copying %s . . .\n", name);
  3021.                 (void) close(fdin);
  3022.                 (void) close(fdout);
  3023.                 ftime.actime = buf1.st_atime;
  3024.                 ftime.modtime = buf1.st_mtime;
  3025.                 (void) utime(output, &ftime);
  3026.                }
  3027.             else
  3028.                {
  3029.                 if (single)
  3030.                    {
  3031.                     if ((name = strrchr(target, '/')) == NULL)
  3032.                         name = target;
  3033.                     else
  3034.                         name++;
  3035.                    }
  3036.                 else
  3037.                     name = file;
  3038.                (void) fprintf(stderr,
  3039.                     "            %s is up to date.\n", name);
  3040.                }
  3041.            }
  3042.         va_end(parm);
  3043.        }
  3044.     return;
  3045.    }
  3046.  
  3047. static void copyerr(which, name)
  3048.     int which;
  3049.     char *name;
  3050.    {
  3051.     char line[MAXLINESIZE];
  3052.  
  3053.     switch (which)
  3054.        {
  3055.         case 1:
  3056.             (void) sprintf(line, "unable to open directory \"%s\"", name);
  3057.             break;
  3058.         case 2:
  3059.             (void) sprintf(line, "unable to open file \"%s\" for reading", name);
  3060.             break;
  3061.         case 3:
  3062.             (void) sprintf(line, "unable to open file \"%s\" for writing", name);
  3063.             break;
  3064.         case 4:
  3065.             (void) sprintf(line, "error writing file \"%s\"", name);
  3066.             break;
  3067.         case 5:
  3068.             (void) sprintf(line, "error reading file \"%s\"", name);
  3069.             break;
  3070.         case 6:
  3071.             (void) sprintf(line, "file \"%s\" does not exist", name);
  3072.             break;
  3073.        }
  3074.     (void) fprintf(stderr, 
  3075. "\n\nFATAL SYSTEM ERROR 9: %s\n        Contact dino@cs.colorado.edu for help\n\n",
  3076.                                                                         line);
  3077.     exit(1);
  3078.    }
  3079.  
  3080. /****************************************************************
  3081.  *
  3082.  *  Makes a directory unless it already exists.  Takes a name of
  3083.  *      a directory, a relative path to that directory and the
  3084.  *      absolute path of the current directory.  The latter two
  3085.  *      can be NULL.
  3086.  *
  3087.  ***************************************************************/
  3088.  
  3089. static void maked(name, relative, absolute)
  3090.     char *name;
  3091.     char *relative;
  3092.     char *absolute;
  3093.    {
  3094.     char dir[MAXPATHLEN];
  3095.     int mask = S_IRWXU | S_IRWXG | S_IRWXO;
  3096.     struct stat buf;
  3097.  
  3098.     if (absolute == NULL)
  3099.        {
  3100.         if (relative == NULL)
  3101.             (void) strcpy(dir, name);
  3102.         else
  3103.             (void) sprintf(dir, "%s/%s", relative, name);
  3104.        }
  3105.     else
  3106.        {
  3107.         if (relative == NULL)
  3108.             (void) sprintf(dir, "%s/%s", absolute, name);
  3109.         else
  3110.             (void) sprintf(dir, "%s/%s/%s", absolute, relative, name);
  3111.        }
  3112.     if (stat(dir, &buf) != 0)
  3113.        {
  3114.         if (errno == ENOENT)
  3115.            {
  3116.             if (mkdir(dir, mask) != 0)
  3117.                {
  3118.                 (void) fprintf(stderr,
  3119. "\n\nFATAL SYSTEM ERROR 8 (%s): Contact dino@cs.colorado.edu for help\n\n", name);
  3120.                 exit(1);
  3121.                }
  3122.             (void) fprintf(stderr,
  3123.                             "\n        Creating directory \"%s\". . .\n", name);
  3124.            }
  3125.         else
  3126.            {
  3127.             (void) fprintf(stderr,
  3128. "\n\nFATAL SYSTEM ERROR 8 (%s): Contact dino@cs.colorado.edu for help\n\n, name");
  3129.             exit(1);
  3130.            }
  3131.        }
  3132.     else
  3133.        {
  3134.         if (! S_ISDIR(buf.st_mode))
  3135.            {
  3136.             (void) fprintf(stderr,
  3137. "\n\nFATAL SYSTEM ERROR 8 (%s): Contact dino@cs.colorado.edu for help\n\n, name");
  3138.             exit(1);
  3139.            }
  3140.         else
  3141.             (void) fprintf(stderr,
  3142.                         "\n        Directory \"%s\" already exists.\n", name);
  3143.        }
  3144.     return;
  3145.    }
  3146.